Re: [flask] Request Mixins
- From:
- Simon Sapin
- Date:
- 2010-09-22 @ 15:00
Le 22/09/2010 16:39, Tim Riley a écrit :
> Hopefully I'm showing my ignorance and this is really easy, but is it
> possible to modify the request/response via a mixin or decorator to
> add additional methods? Specifically I'm trying to take
> blobstore.py[1] and xmpp.py[2] from tipfy and modify them to use in
> flask. Any guidance would be greatly appreciated.
>
> [1]
http://code.google.com/p/tipfy-ext-blobstore/source/browse/tipfy/ext/blobstore.py
> [2] http://code.google.com/p/tipfy-ext-xmpp/source/browse/tipfy/ext/xmpp.py
Hi,
Yes it is possible.
Flask is based on Werkzeug and Werkzeug’s own Request and Response
classes are based on BaseRequest and BaseResponse plus several mixin
classes, with multiple inheritance.
See the source and documentation :
http://dev.pocoo.org/projects/werkzeug/browser/werkzeug/wrappers.py
http://werkzeug.pocoo.org/documentation/dev/wrappers.html
Instead of mixins, you can just subclass Request and Response to add
methods.
--
Simon Sapin