Ben Bangert avatar Ben Bangert committed 066e7a4

Fix cache region check location. Update session docs.

Comments (0)

Files changed (2)

     def decorate(func):
         namespace = util.func_namespace(func)
         def cached(*args):
+            if region not in cache_regions:
+                raise BeakerException('Cache region not configured: %s' % region)
             reg = cache_regions[region]
             if not reg.get('enabled', True):
                 return func(*args)
             
             if not cache[0]:
-                if region not in cache_regions:
-                    raise BeakerException('Cache region not configured: %s' % region)
                 cache[0] = Cache._get_cache(namespace, reg)
             
             cache_key = " ".join(map(str, deco_args + args))

beaker/docs/sessions.rst

 This is not usually the case however, as a session generally should not be
 saved should something catastrophic happen during a request.
 
+.. note::
+    
+    When using the Beaker middleware, you **must call save before the headers
+    are sent to the client**. Since Beaker's middleware watches for when the
+    ``start_response`` function is called to know that it should add its
+    cookie header, the session must be saved before its called.
+
 
 Auto-save
 ---------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.