Commits

mlk  committed e197953

fix req.cache_control + tests (CacheControl class is still can be improved to be a proper view on environ/headerslist)

  • Participants
  • Parent commits 45e0bcd

Comments (0)

Files changed (2)

File tests/test_request.txt

     >>> req.user_agent
     'MSIE-Win'
 
+    >>> req.cache_control
+    <CacheControl ''>
+    >>> req.cache_control.no_cache = True
+    >>> req.cache_control.max_age = 0
+    >>> req.cache_control
+    <CacheControl 'max-age=0, no-cache'>
+
+Unfortunately .cache_control is not a view:
+
+    >>> 'cache-control' in req.headers
+    False
+    >>> req.cache_control = req.cache_control
+    >>> 'cache-control' in req.headers
+    True
+    >>> req.headers['cache-control']
+    'max-age=0, no-cache'
+    >>> req.cache_control = {'no-transform': None, 'max-age': 100}
+    >>> req.headers['cache-control']
+    'max-age=100, no-transform'
+
+
+
 Accept-* headers are parsed into read-only objects that support
 containment tests, and some useful methods.  Note that parameters on
 mime types are not supported.
         ...
     AttributeError: 'BaseRequest' object has no attribute 'foo'
 
-  
 
 
 
 
+

File webob/request.py

 from webob.acceptparse import Accept, MIMEAccept, NilAccept, MIMENilAccept, NoAccept
 from webob.datastruct import EnvironHeaders
 from webob.multidict import TrackableMultiDict, MultiDict, UnicodeMultiDict, NestedMultiDict, NoVars
+from webob.cachecontrol import CacheControl
 
 from webob.descriptors import *
 from webob.datetime_utils import *
             value = ""
         if isinstance(value, dict):
             value = CacheControl(value, type='request')
-        elif isinstance(value, CacheControl):
+        if isinstance(value, CacheControl):
             str_value = str(value)
             env['HTTP_CACHE_CONTROL'] = str_value
             env['webob._cache_control'] = (str_value, value)