SVN: r25378 - in trunk/quixote: . form
Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Fri, 15 Oct 2004 16:35:36 -0400
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: nascheme
Date: 2004-10-15 16:35:27 -0400 (Fri, 15 Oct 2004)
New Revision: 25378
Modified:
trunk/quixote/form/compatibility.py
trunk/quixote/form/form.py
trunk/quixote/http_request.py
trunk/quixote/publish.py
Log:
Add HTTPRequest.get_query() method. Use it instead of the QUERY_STRING
environment variable.
Modified: trunk/quixote/form/compatibility.py
===================================================================
--- trunk/quixote/form/compatibility.py 2004-10-15 20:20:15 UTC (rev 25377)
+++ trunk/quixote/form/compatibility.py 2004-10-15 20:35:27 UTC (rev 25378)
@@ -53,7 +53,7 @@
def get_action_url(self):
action_url = url_quote(get_path())
- query = get_request().get_environ("QUERY_STRING")
+ query = get_request().get_query()
if query:
action_url += "?" + query
return action_url
Modified: trunk/quixote/form/form.py
===================================================================
--- trunk/quixote/form/form.py 2004-10-15 20:20:15 UTC (rev 25377)
+++ trunk/quixote/form/form.py 2004-10-15 20:35:27 UTC (rev 25378)
@@ -99,7 +99,7 @@
def _get_default_action_url(self):
request = get_request()
action_url = url_quote(request.get_path())
- query = request.get_environ("QUERY_STRING")
+ query = request.get_query()
if query:
action_url += "?" + query
return action_url
Modified: trunk/quixote/http_request.py
===================================================================
--- trunk/quixote/http_request.py 2004-10-15 20:20:15 UTC (rev 25377)
+++ trunk/quixote/http_request.py 2004-10-15 20:35:27 UTC (rev 25378)
@@ -163,7 +163,7 @@
self.environ['PATH_INFO'] = path
def process_inputs(self):
- query = self.environ.get('QUERY_STRING')
+ query = self.get_query()
if query:
self.form.update(parse_query(query))
length = self.environ.get('CONTENT_LENGTH', 0)
@@ -329,6 +329,13 @@
else:
assert 0, "Unexpected value for n (%s)" % n
+ def get_query(self):
+ """() -> string
+
+ Return the query component of the URL.
+ """
+ return self.environ.get('QUERY_STRING', '')
+
def get_url(self, n=0):
"""get_url(n : int = 0) -> string
Modified: trunk/quixote/publish.py
===================================================================
--- trunk/quixote/publish.py 2004-10-15 20:20:15 UTC (rev 25377)
+++ trunk/quixote/publish.py 2004-10-15 20:35:27 UTC (rev 25378)
@@ -233,29 +233,22 @@
seconds = now - start_time
timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(now))
- env = request.environ
-
- # Under Apache, REQUEST_URI == SCRIPT_NAME + PATH_INFO.
- # Not everyone uses Apache, so we have to stick to
- # environment variables in the CGI spec. Note that this
- # relies on PATH_INFO under IIS being fixed by HTTPRequest,
- # because IIS gets it wrong.
- request_uri = env.get('SCRIPT_NAME') + env.get('PATH_INFO', '')
- query = env.get('QUERY_STRING', '')
+ request_uri = request.get_path()
+ query = request.get_query()
if query:
- query = "?" + query
- proto = env.get('SERVER_PROTOCOL')
+ request_uri += "?" + query
+ proto = request.get_environ('SERVER_PROTOCOL')
self.access_log.write('%s %s %s %d "%s %s %s" %s %r %0.2fsec\n' %
- (request.environ.get('REMOTE_ADDR'),
+ (request.get_environ('REMOTE_ADDR'),
user,
timestamp,
os.getpid(),
request.get_method(),
- request_uri + query,
+ request_uri,
proto,
request.response.status_code,
- request.environ.get('HTTP_USER_AGENT', ''),
+ request.get_environ('HTTP_USER_AGENT', ''),
seconds
))
@@ -363,7 +356,7 @@
def _generate_internal_error(self, request):
- admin = request.environ.get('SERVER_ADMIN',
+ admin = request.get_environ('SERVER_ADMIN',
"<i>email address unknown</i>")
return INTERNAL_ERROR_MESSAGE % admin