lib/http.py
branchsites
changeset 42 5a72c00c4ae4
parent 25 8f143b1ce0d1
--- a/lib/http.py	Sun Feb 08 00:29:36 2009 +0200
+++ b/lib/http.py	Sun Feb 08 02:29:23 2009 +0200
@@ -29,8 +29,17 @@
 
         # parse query args
         self.arg_dict = cgi.parse_qs(self.arg_str, True)
-    
-    def get_script_dir (self) :
+ 
+    @property
+    def site_host (self) :
+        """
+            Returns the site's hostname (DNS name)
+        """
+        
+        return self.env['HTTP_HOST']
+  
+    @property
+    def site_root (self) :
         """
             Returns the URL path to the requested script's directory with no trailing slash, i.e.
 
@@ -41,7 +50,8 @@
 
         return os.path.dirname(self.env['SCRIPT_NAME']).rstrip('/')
     
-    def get_page_prefix (self) :
+    @property
+    def page_prefix (self) :
         """
             Returns the URL path root for page URLs, based on REQUEST_URI with PATH_INFO removed
 
@@ -68,7 +78,7 @@
         
         # trim
         return request_path[:-len(page_name)].rstrip('/')
-
+    
     def get_page_name (self) :
         """
             Returns the requested page path with no leading slash, i.e.
@@ -88,6 +98,13 @@
 
         else :
             return ''
+    
+    def get_args (self) :
+        """
+            Iterate over all available (key, value) pairs from the query string
+        """
+
+        return cgi.parse_qsl(self.arg_str)
 
 class Response (object) :
     """