[Twisted-web] Adding data to the request
matt at pollenation.net
Thu Sep 16 03:23:25 MDT 2004
On Thu, 2004-09-16 at 09:36, Syver Enstad wrote:
> Is there a supported way for adding data to a twisted.web request
> object. I am not thinking about the session, because I only want the
> data to last the current request, the typical use is for a resource to
> add some data that would be used by a child resource. I know I could
> use the args dictionary but that seems a little awkward as that is
> supposed to contain the query string/post for the page.
Request is Componentized so you can attach data to the request. Here's
how it works ...
Define an interface and an implementation:
__implements__ = IFoo,
To associate some Foo data with the request do:
foo = Foo()
foo.bar = 'bar'
And finally, do something like this to retrieve the data from the
foo = request.getComponent(IFoo)
/ \__ Matt Goodall, Pollenation Internet Ltd
\__/ \ w: http://www.pollenation.net
__/ \__/ e: matt at pollenation.net
/ \__/ \ t: +44 (0)113 2252500
/ \ Any views expressed are my own and do not necessarily
\__/ reflect the views of my employer.
More information about the Twisted-web