[mod_python] question - Getting/Setting Cookies

Nikolay Alexiev alexiev at activesolutions.bg
Thu Feb 12 11:49:21 EST 2004


# I use this
cookies = SimpleCookie()
cookies['cookie1'] = value1
cookies['cookie2'] = value2
req.headers_out.add('Set-Cookie', cookies.output(header='', 
sep='\r\nSet-Cookie:'))


Bud P. Bruegger wrote:

> Hi David,
>
> I don't know much about mod-python--just planning to use it myself.  
> But maybe this is what you're looking for:
>
> http://www.modpython.org/live/mod_python-3.1.2b/doc-html/pyapi-cookie.html 
>
>
> I came across this before and had a hell of a time finding it again.  
> Trouble seems to be that it is in the 3.1 beta version and the home 
> page links to the stable manual (3.0).
>
> cheers
> -b
>
> At 17.26 12/02/2004 +1300, you wrote:
>
>> Hi,
>>
>> I've been a longtime user of Cookie.SimpleCookie, as an easy way of 
>> getting/setting cookies within Python CGI scripts.
>>
>> A couple of days ago, I installed mod_python.
>>
>> While I'm impressed with the performance gain mod_python is giving me 
>> with its CGI handler, I suspect things can run faster still if I 
>> write my own handler.
>>
>> Only problem is - I can't see a trivial way to get a Cookie object 
>> from the 'req' object which gets passed to one's mod_python handler.
>>
>> So my question is - is there any code for getting a Cookie object 
>> from the 'req' object?
>>
>> It's not too hard to write one - just a bit of farting about. But I'd 
>> rather not 'reinvent a wheel' if someone else has already done this.
>>
>> But if I have to write it myself, here's another question - how do I 
>> get the raw http headers from 'req' as a bulk string, which I can 
>> pass to Cookie.load()?
>>
>> Thanks in advance for your help
>>
>> -- 
>>
>> Kind regards
>> David
>>
>> -- 
>>
>> leave this line intact so your email gets through my junk mail filter
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>
> ------------------------------------------------------------------------------------------------- 
>
> Ing. Bud P. Bruegger, Ph.D.                 bud at comune.grosseto.it
> Servizio Elaborazione Dati                    0564-488 577 (voice)
> Comune di Grosseto                            0564- 21139 (fax)
> Via Ginori, 43
> 58100 Grosseto
>
> Collaborazione Open Source per la CIE http://www.comune.grosseto.it/cie/
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python




More information about the Mod_python mailing list