[albatross-users] python 2.2-ism in httpdapp
Gregory Bond
gnb at itga.com.au
Fri Sep 26 11:28:33 EST 2003
httpdapp.py (in 1.10) does
from urlparse import urlsplit
which is a 2.2-ism and breaks on my 2.1 installation.
The attached patch fixes that, on the dubious assumption that I understood the
code in the first place!
-------------- next part --------------
--- albatross/httpdapp.py.DIST Sat Jul 12 14:42:51 2003
+++ albatross/httpdapp.py Fri Sep 26 11:21:16 2003
@@ -9,7 +9,18 @@
import BaseHTTPServer
import cgi
from cStringIO import StringIO
-from urlparse import urlsplit
+
+try:
+ from urlparse import urlsplit
+ def parse(s):
+ return urlsplit(s.split()[1])[3]
+except ImportError:
+ # Python 2.1, so use the old and inferior urlparse
+ from urlparse import urlparse
+ def parse(s):
+ return urlparse(s.split()[1])[4]
+
+
class Request:
@@ -33,7 +44,7 @@
def parse_get_fields(self):
"""Extract fields from query string"""
- qs = urlsplit(self._req.requestline.split()[1])[3]
+ qs = parse(self._req.requestline)
if not qs:
return {}
return cgi.parse_qs(qs)
More information about the Albatross-users
mailing list