[Twisted-web] web2 response.setCookie and request.getCookie shortcuts?

David Reid dreid at dreid.org
Wed Nov 16 17:22:19 MST 2005


On Wed, 2005-11-16 at 17:42 -0500, Clark C. Evans wrote:
> I'm still having fun with web2, it is such a huge improvment over
> twisted.web and I'm absolutely thrilled with it.  However, I have
> a few suggestions:
>  
>    1. It would be supreme if render() and locateChild() just provided
>       me the Request object; the incantation to ctx.locate() seems a
>       tedious an unnecessary step.

You're in luck context is going away.  Far far away never to be seen again.  
As soon as an appropriate method for per-request data can be decided upon.

>    2. I would love a request.getCookie('cookie-name') and 
>       response.setCookie('cookie-name','cookie-value', path = '/')
>       helper; that adds the given cookie to the current list.

I'm personally against polluting the request and response interfaces
with this kind of stuff, in my opinion cookies are just headers, they
shouldn't be special.  I wouldn't be opposed to higher level cookie
management that presented a similar interface to both the client and the
server developer, but I probably won't have any interest in writing
it.  

>    3. Make the 'path' in the Cookie constructor and setCookie default
>       to '/'.  Almost all of the time you want your cookies to be 
>       site-wide; adding path = '/' to each request adds a point of
>       failure that makes the system less usable.

I'm all for sane-defaults, but I'm not sure this is one.  I'll let foom
decide.

-David




More information about the Twisted-web mailing list