twilio/flask-restful — pull request #241 by jrandall (2014-05-29 14:56:18+00:00)
Title: Updates Url Field section of fields documentation

The current RandomNumber example in the fields documentation is confusing because it does not work unless the object being marhsalled include an attribute named 'random' (which is then ignored).

This is because the default output method in fields.Raw includes (fields.py#L107) an early return of default in case the value returned by `get_value` is None, meaning that the `self.format(...)` method never gets called unless the object contains an attribute by the same name as the field key.

This commit changes the RandomNumber example to modify the output method instead of the format method. I suppose it could also include a call through to self.format(random.random()) but that seems rather pointless in this instance.