changeset 4203:f4a92d2ee616

Missing in_-prefix for cache-controls and more customization for TestRequest
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 09 Jul 2008 15:55:10 +0200
parents 7e43fdd2d2c0
children 424800cd9596
files MoinMoin/web/request.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/request.py	Wed Jul 09 02:01:08 2008 +0200
+++ b/MoinMoin/web/request.py	Wed Jul 09 15:55:10 2008 +0200
@@ -39,6 +39,12 @@
 
     data = WerkzeugResponse.data
     stream = WerkzeugResponse.stream
+    cache_control = WerkzeugResponse.cache_control
+
+    def in_cache_control(self):
+        cache_control = self.environ.get('HTTP_CACHE_CONTROL')
+        return parse_cache_control_header(cache_control)
+    in_cache_control = cached_property(in_cache_control)
 
     def in_headers(self):
         return EnvironHeaders(self.environ)
@@ -57,7 +63,7 @@
 class TestRequest(Request):
     def __init__(self, path="/", query_string=None, method='GET',
                  input_stream=None, content_type=None, content_length=0,
-                 form_data=None):
+                 form_data=None, **env):
         self.errors_stream = StringIO()
         self.output_stream = StringIO()
 
@@ -72,6 +78,9 @@
                                  content_length=content_length,
                                  errors_stream=self.errors_stream)
 
+        for k,v in env.items():
+            environ[k] = v
+
         environ['HTTP_USER_AGENT'] = 'MoinMoin/TestRequest'
         super(TestRequest, self).__init__(environ)