[mod_python] Is PSP block embeddable to another PSP block ?

Graham Dumpleton grahamd at dscpl.com.au
Mon Sep 25 04:24:30 EDT 2006


On 23/09/2006, at 12:08 AM, Padmashree B wrote:

>
> Hi.. i am trying to figure out cgi code written using Python..
> I create a cookie using
> import Cookie
> c=Cookie.SimpleCookie()
> c["cookie1"]="value1"
>
> Now when I want to retrive the cookie value in CGI written using  
> python do I necessary have to depend on the environment variable  
> HTTP_COOKIE which is set in os.environ..
>
> as in
>
> thiscookie = Cookie.SimpleCookie( )
> if os.environ.has_key ('HTTP_COOKIE'):
>     thiscookie.load(os. environ['HTTP_COOKIE'])
>  print thiscookie['aparam']. value
>
> Is there any other way to do without using the variable HTTP_COOKIE  
> set in os.environ..
>
> Also, is it ok to use this code in mod_python.. as in getting the  
> cookie values using the environment variable HTTP_COOKIE...

Programming a CGI script with Python is a totally different thing to  
using
mod_python. With CGI, Apache is executing your script as an independent
program each time a request arrives which is for a URL which maps to the
script. In mod_python, the Python interpreter is embedded as an integral
part of Apache and stays resident between requests.

Thus, this question isn't even appropriate for this mailing list.

If you want questions answered purely on how to program CGI scripts in
Python, you would be better off posting on comp.lang.python at Google
groups site.

When you work out how CGI is different to mod_python and work out that
you need to convert your CGI scripts for use under mod_python, then by
all means return and ask your mod_python specific questions here.

Graham



More information about the Mod_python mailing list