Commits

Ben Bangert committed 251c42a

* Add ``webtest_varname`` option to configuration to optionally include
the session value in the environ vars when using Beaker with WebTest.

  • Participants
  • Parent commits 066e7a4

Comments (0)

Files changed (4)

+Release 1.5.5 (**tip**)
+=======================
+
+* Add ``webtest_varname`` option to configuration to optionally include
+  the session value in the environ vars when using Beaker with WebTest.
+
 Release 1.5.4 (6/16/2010)
 =========================
 

beaker/docs/configuration.rst

     
     Some of these back-ends require the url option as listed below.
 
+webtest_varname (**optionall**, string)
+    The name of the attribute to use when stashing the session object into
+    the environ for use with WebTest. The name provided here is where the 
+    session object will be attached to the WebTest TestApp return value.
+
 url (**optional**, string)
     URL is specific to use of either ext:memcached or ext:database. When using
     one of those types, this option is **required**.

beaker/middleware.py

         environ[self.environ_key] = session
         environ['beaker.get_session'] = self._get_session
         
+        if 'paste.testing_variables' in environ and 'webtest_varname' in self.options:
+            environ['paste.testing_variables'][self.options['webtest_varname']] = session
+        
         def session_start_response(status, headers, exc_info = None):
             if session.accessed():
                 session.persist()
         ('timeout', (int, types.NoneType), "Session timeout must be an "
          "integer."),
         ('auto', (bool, types.NoneType), "Session is created if accessed."),
+        ('webtest_varname', (str, types.NoneType), "Session varname must be "
+         "a string."),
     ]
     return verify_rules(params, rules)