zopefoundation / bobo

Lightweight web framework that only does publishing.
82 stars 11 forks source link

RFC: Safer argument handling using argument and return annotations #7

Open jimfulton opened 10 years ago

jimfulton commented 10 years ago

For Python 3, it would be great to do things like:

@bobo.put('/someroute')
def put_some(self, x: int, when: iso_datetime) -> bobo.JSON:
      ...

On input, this would allow you to assure inputs are of a given type, by checking and possible converting. This is even handy with JSON input, as the example demonstrates.

On output, you can have greater control over response generation, for example by using a custom JSON encoder or by applying templates to output.