[Twisted-web] Sessions and Authentication for Web2

Valentino Volonghi aka Dialtone dialtone at divmod.com
Thu Nov 17 15:24:02 MST 2005

On Thu, Nov 17, 2005 at 04:29:36PM -0500, Clark C. Evans wrote:
> | def sessionfilter(req, res, ctx):
> |     # do session handling here
> | 
> | def authenticationfilter(req, res, ctx):
> |     # do authentication handling here
> |
> 1. How do I know what the response is before I even authenticate or
>    create a session?

In order to start writing the response to the outside you have to call

So you can 'easily' avoid transmitting anything but keep producing the page with
a BufferedStream that can consume but not produce until you tell it to. In
this way the environment will change without any output and then you will be
able to see the changes at the end and decide consequently.

> 2. Which comes first, I assume session then authentication.

Easily changeable by changing the order of Request.responseFilters

> 3. These need to come _before_ any of my other resources get
>    the request.

I don't understand the implication of this. Can you elaborate a bit? :)

> It seems that the dispatch mechansim might need a way to "register"
> that a filter should be applied at the end of processing; so that
> once the Response is generated, it can be wrapped on the way out.

There already is:
Request.addResponseFilter(f, atEnd=False)

Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-web/attachments/20051117/1eb57077/attachment.pgp

More information about the Twisted-web mailing list