changeset 1116:4aae51ce0172

support if-modified-since and if-none-match for Twisted, Standalone and CLI, cleanup
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 01 Aug 2006 10:21:06 +0200
parents a349adcabffe
children d25b3f1b25f3
files MoinMoin/request/CLI.py MoinMoin/request/STANDALONE.py MoinMoin/request/TWISTED.py MoinMoin/request/__init__.py
diffstat 4 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/request/CLI.py	Tue Aug 01 10:01:44 2006 +0200
+++ b/MoinMoin/request/CLI.py	Tue Aug 01 10:21:06 2006 +0200
@@ -26,6 +26,8 @@
         self.http_host = 'localhost'
         self.http_referer = ''
         self.script_name = '.'
+        self.if_modified_since = None
+        self.if_none_match = None
         RequestBase.__init__(self, properties)
         self.cfg.caching_formats = [] # don't spoil the cache
         self.initTheme() # usually request.run() does this, but we don't use it
--- a/MoinMoin/request/STANDALONE.py	Tue Aug 01 10:01:44 2006 +0200
+++ b/MoinMoin/request/STANDALONE.py	Tue Aug 01 10:21:06 2006 +0200
@@ -33,6 +33,10 @@
             self.http_user_agent = sa.headers.getheader('user-agent', '')
             co = filter(None, sa.headers.getheaders('cookie'))
             self.saved_cookie = ', '.join(co) or ''
+            self.if_modified_since = (sa.headers.getheader('if-modified-since')
+                                      or self.if_modified_since)
+            self.if_none_match = (sa.headers.getheader('if-none-match')
+                                  or self.if_none_match)
 
             # Copy rest from standalone request   
             self.server_name = sa.server.server_name
--- a/MoinMoin/request/TWISTED.py	Tue Aug 01 10:01:44 2006 +0200
+++ b/MoinMoin/request/TWISTED.py	Tue Aug 01 10:21:06 2006 +0200
@@ -23,6 +23,8 @@
             self.http_accept_language = self.twistd.getHeader('Accept-Language')
             self.saved_cookie = self.twistd.getHeader('Cookie')
             self.http_user_agent = self.twistd.getHeader('User-Agent')
+            self.if_modified_since = self.twistd.getHeader('If-Modified-Since')
+            self.if_none_match = self.twistd.getHeader('If-None-Match')
 
             # Copy values from twisted request
             self.server_protocol = self.twistd.clientproto
--- a/MoinMoin/request/__init__.py	Tue Aug 01 10:01:44 2006 +0200
+++ b/MoinMoin/request/__init__.py	Tue Aug 01 10:21:06 2006 +0200
@@ -315,8 +315,7 @@
         """
         # Values we can just copy
         self.env = env
-        self.http_accept_language = env.get('HTTP_ACCEPT_LANGUAGE',
-                                            self.http_accept_language)
+        self.http_accept_language = env.get('HTTP_ACCEPT_LANGUAGE', self.http_accept_language)
         self.server_name = env.get('SERVER_NAME', self.server_name)
         self.server_port = env.get('SERVER_PORT', self.server_port)
         self.saved_cookie = env.get('HTTP_COOKIE', '')
@@ -326,6 +325,8 @@
         self.request_method = env.get('REQUEST_METHOD', None)
         self.remote_addr = env.get('REMOTE_ADDR', '')
         self.http_user_agent = env.get('HTTP_USER_AGENT', '')
+        self.if_modified_since = env.get('If-modified-since') or env.get(cgiMetaVariable('If-modified-since'))
+        self.if_none_match = env.get('If-none-match') or env.get(cgiMetaVariable('If-none-match'))
 
         # REQUEST_URI is not part of CGI spec, but an addition of Apache.
         self.request_uri = env.get('REQUEST_URI', '')
@@ -336,7 +337,6 @@
         self.setHost(env.get('HTTP_HOST'))
         self.fixURI(env)
         self.setURL(env)
-        self.getCachingHeaders(env)
         #self.debugEnvironment(env)
 
     def setHttpReferer(self, referer):
@@ -431,13 +431,6 @@
             self.request_uri = self.makeURI()
         self.url = self.http_host + self.request_uri
 
-    def getCachingHeaders(self, env):
-        self.if_modified_since = (env.get('If-modified-since') or
-                                  env.get(cgiMetaVariable('If-modified-since')))
-        self.if_none_match = (env.get('If-none-match') or
-                                  env.get(cgiMetaVariable('If-none-match')))
-        self.log("inm: %s ims: %s" % (self.if_none_match, self.if_modified_since))
-
     def rewriteHost(self, env):
         """ Rewrite http_host transparently