Kaydet (Commit) 9c6cedaa authored tarafından Guido van Rossum's avatar Guido van Rossum

The official name of the whole thing is now "Python FAQ Wizard";

and it's in beta testing now.

Renamed the cookie id to Python-FAQ-Wizard and fixed some bugs
related to cookie processing.
üst a78a3c30
...@@ -96,7 +96,7 @@ class FAQServer: ...@@ -96,7 +96,7 @@ class FAQServer:
return value return value
def do_frontpage(self): def do_frontpage(self):
self.prologue("Python FAQ (beta test) Front Page") self.prologue("Python FAQ Wizard (beta test)")
print """ print """
<UL> <UL>
<LI><A HREF="faq.py?req=index">FAQ index</A> <LI><A HREF="faq.py?req=index">FAQ index</A>
...@@ -574,7 +574,7 @@ class FAQServer: ...@@ -574,7 +574,7 @@ class FAQServer:
print "<PRE>%s</PRE>" % cgi.escape(output) print "<PRE>%s</PRE>" % cgi.escape(output)
def set_cookie(self, author, email, password): def set_cookie(self, author, email, password):
name = "Python-FAQ-ID" name = "Python-FAQ-Wizard"
value = "%s/%s/%s" % (author, email, password) value = "%s/%s/%s" % (author, email, password)
import urllib import urllib
value = urllib.quote(value) value = urllib.quote(value)
...@@ -587,18 +587,19 @@ class FAQServer: ...@@ -587,18 +587,19 @@ class FAQServer:
def get_cookie(self): def get_cookie(self):
if not os.environ.has_key('HTTP_COOKIE'): if not os.environ.has_key('HTTP_COOKIE'):
return "", "" return "", "", ""
raw = os.environ['HTTP_COOKIE'] raw = os.environ['HTTP_COOKIE']
words = string.split(raw, ';') words = map(string.strip, string.split(raw, ';'))
cookies = {} cookies = {}
for word in words: for word in words:
i = string.find(word, '=') i = string.find(word, '=')
if i >= 0: if i >= 0:
key, value = word[:i], word[i+1:] key, value = word[:i], word[i+1:]
cookies[key] = value cookies[key] = value
if not cookies.has_key('Python-FAQ-ID'): print "\n<PRE>Cookies:", cookies, "</PRE>"
if not cookies.has_key('Python-FAQ-Wizard'):
return "", "", "" return "", "", ""
value = cookies['Python-FAQ-ID'] value = cookies['Python-FAQ-Wizard']
import urllib import urllib
value = urllib.unquote(value) value = urllib.unquote(value)
words = string.split(value, '/') words = string.split(value, '/')
...@@ -613,7 +614,7 @@ class FAQServer: ...@@ -613,7 +614,7 @@ class FAQServer:
author = self.author author = self.author
email = self.email email = self.email
password = self.password password = self.password
if not author or not email: if not author or not email or not password:
a, e, p = self.get_cookie() a, e, p = self.get_cookie()
author = author or a author = author or a
email = email or e email = email or e
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment