Problem w/Cookies Module?

junkster at rochester.rr.com junkster at rochester.rr.com
Thu May 11 10:48:58 EDT 2000


	I'm having some odd-ball problems with v2.25 (05/03/2000) of
the Cookie module.  I originally thought that it was the ODBC process
behind this web CGI that was causing the lockup, but through trial and
error testing, it appears to be related to the cookies module.

        The program I've attached, seems to "lock up".

	Here's the steps I can use to reproduce it:

		1) Browse to the CGI (i.e.
http://localhost/webboard/homepages/test_cookies.py)
			- Writes the cookies initially
		2) Hit "Refresh" which will read the cookies from the
environmental value
			- Check to ensure it looks AOK

		3) Hit "Refresh" again, the web browser will sit there
until it times out.

	This is happening extremely reliably on the Win NT v4 (Service
Pack 6a) unit that I'm testing this code on.

	Has anyone heard of this (or other) problems?  This is the
first serious attempt to use the cookie module, so I'm not sure if this
is a implementation problem, or a code error.

			- Benjamin

import cgi
import cookie
import os
import sys
import string
import time


def	load_cookie ():
	user_info = cookie.SmartCookie()
	try:
		#
		#	Load Cookie
		#
		user_info.load (os.environ["HTTP_COOKIE"])
	except KeyError:
		# 	Cookie Does not exist
		pass

	return user_info

def	get_cookie_data (cookie_data, keyword):
	data = ""
	try:
		data = cookie_data[keyword].value
	except:
		pass
	return data

def	output_cookie ( cookie_data ):
	print cookie_data

cookie_data = load_cookie()

print "Context-Type: Text/Html"
if (len(sys.argv) > 1) and (string.upper(sys.argv[1]) == "LOGOUT"):
	cookie_data["user_name"]	= ""
	cookie_data["password"]  	= ""
	cookie_data["blah"]		= ""
	output_cookie (cookie_data)

elif len(cookie_data) == 0:
	cookie_data["user_name"] 	= "jjavier"
	cookie_data["password"]  	= "jjavier"
	cookie_data["real_name"]	= "Javier Jimenez Gomez"
	output_cookie (cookie_data)

print
print "<HTML> <HEAD> </HEAD> <BODY>"
print "Loaded from Cookie:"
print
print "<UL>"
print "<LI> User Name : ", get_cookie_data (cookie_data, "user_name")
print "<LI> password  : ", get_cookie_data (cookie_data, "password")
print "<LI> Real Name : ", get_cookie_data (cookie_data, "real_name")
print "</UL>"

print "</BODY>"
print "</HTML>"


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list