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

James Y Knight foom at fuhm.net
Fri Nov 18 00:13:49 MST 2005


On Nov 17, 2005, at 9:50 PM, glyph at divmod.com wrote:
> On Thu, 17 Nov 2005 15:29:34 -0500, "Clark C. Evans"  
> <cce at clarkevans.com> wrote:
>
>
>> The acceptable languages that the _response_ is allowed to take  
>> can be
>> found in the 'Accept-Language' header.  This has the advantage of
>> allowing more than one language choice, eighted by preference and
>> typically auto-configured by your browser from the operating system
>> defaults.  In most browsers this setting can be changed; for example,
>> in Firefox go to about:config and navigate to intl.accept_languages.
>>
>
> In this case, since the 'request' object is available, simply pass  
> the appropriate data from the header in question down to the object  
> which needs to be rendered.  In this case there is even less need  
> for the context: a regular HTTP request encapsulates all the data  
> you need!

Of course as noted before, it is often a requirement that a user be  
able to override this setting via an interface in the web application  
itself. Ideally that wouldn't be required, but idealism isn't often  
achievable when web browsers are involved. :) The override may take  
the form of a cookie, data in a session, part of the url, or whatever  
else app specific. In the way I'd envision creating an application,  
processing the language pref inputs into the single "preferred  
languages order" attribute takes place in a resource near the top of  
the graph, for use by all resources under it in the application. Said  
resource has to communicate the information somehow.

I like CCE's description of his processing stages -- it seems to  
match the way I think as well, although he takes it to more of an  
extreme than I would.

James



More information about the Twisted-web mailing list