SVN: r22134 - trunk/quixote

Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Fri, 1 Aug 2003 10:31:00 -0400
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Author: nascheme
Date: 2003-08-01 10:17:39 -0400 (Fri, 01 Aug 2003)
New Revision: 22134

Modified:
   trunk/quixote/http_request.py
   trunk/quixote/publish.py
   trunk/quixote/util.py
Log:
Add HTTPRequest.get_method().


Modified: trunk/quixote/util.py
==============================================================================
--- trunk/quixote/util.py	2003-08-01 14:13:37 UTC (rev 22133)
+++ trunk/quixote/util.py	2003-08-01 14:17:39 UTC (rev 22134)
@@ -32,8 +32,7 @@
     """
 
     # Get contents of POST body
-    method = request.environ['REQUEST_METHOD']
-    if method != 'POST':
+    if request.get_method() != 'POST':
         request.response.set_status(405, "Only the POST method is accepted")
         return "XML-RPC handlers only accept the POST method."
 

Modified: trunk/quixote/publish.py
==============================================================================
--- trunk/quixote/publish.py	2003-08-01 14:13:37 UTC (rev 22133)
+++ trunk/quixote/publish.py	2003-08-01 14:17:39 UTC (rev 22134)
@@ -253,7 +253,6 @@
             timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(now))
 
             env = request.environ
-            method = env.get('REQUEST_METHOD')
 
             # Under Apache, REQUEST_URI == SCRIPT_NAME + PATH_INFO.
             # Not everyone uses Apache, so we have to stick to
@@ -271,7 +270,7 @@
                                     str(user),
                                     timestamp,
                                     os.getpid(),
-                                    method,
+                                    request.get_method(),
                                     request_uri + query,
                                     proto,
                                     request.response.status_code,

Modified: trunk/quixote/http_request.py
==============================================================================
--- trunk/quixote/http_request.py	2003-08-01 14:13:37 UTC (rev 22133)
+++ trunk/quixote/http_request.py	2003-08-01 14:17:39 UTC (rev 22134)
@@ -146,8 +146,7 @@
         """Process request inputs.
         """
         self.start_time = time.time()
-        method = self.environ.get('REQUEST_METHOD', 'GET')
-        if method != 'GET':
+        if self.get_method() != 'GET':
             # Avoid consuming the contents of stdin unless we're sure
             # there's actually form data.
             if self.content_type == "multipart/form-data":
@@ -189,6 +188,11 @@
     def get_form_var (self, var_name, default=None):
         return self.form.get(var_name, default)
 
+    def get_method (self):
+        """Returns the HTTP method for this request
+        """
+        return self.environ.get('REQUEST_METHOD', 'GET')
+
     def formiter (self):
         return self.form.iteritems()