CGI questions

Michael Hall olc at ninti.com
Tue Jun 4 13:41:24 EDT 2002


I've been using PHP for a couple of years now, but have begun to look at
Python as a CGI language. So far so good, I really like writing straight
OO code and keeping all the HTML spaghetti out of the way in templates.
Anyway, a couple of questions:

1.
Does Python have the same or a similar problem that PHP had until recently 
with regard to automatic global registration of GET, POST and COOKIE
variables within a script's namespace? My guess is that it doesn't, but
I'd like to know for sure.
In other words, is all user input in the form of query string or POST
variables 'filtered' through cgi.Fieldstorage? Is user input ever directly
available to the script? 
Let's say I have a variable 'loggedon' in my script. If a user passes
'loggedon=yes' in a query string to my script, will it have any effect or
would it have to be accessed via something like this first:

form = cgi.Fieldstorage
loggedon = form["loggedon"].value

2.
I'm trying to use the md5 module to create a session id string. It
produces some output, but it is pretty weird stuff, not the 32 character
alphanumeric string I'd expect from PHP. Most of it is definitely not
[a-zA-Z0-9], and it is around 10 characters long. How can I get a PHP
style md5 result?

3.
What is the decimal bit on the end of time.time()'s output? Hundredths of
a second?

4.
Is the following Python the (best) equivalent to the PHP?

PHP				Python
ereg("bit","bigbits")		re.compile("bit").search("bigbits",1)
				

TIA 


--------------------------------
Michael Hall     ninti at ninti.com
--------------------------------







More information about the Python-list mailing list