1. brianfrantz
  2. beaker

Commits

Ben Bangert  committed 0d9139a

* Update option for ``cookie_expires`` so that it can now handle an integer
which will be used as the seconds till the cookie expires.

  • Participants
  • Parent commits afde560
  • Branches trunk

Comments (0)

Files changed (4)

File CHANGELOG

View file
  • Ignore whitespace
 Release 1.6 (**tip**)
 =======================
 
+* Update option for ``cookie_expires`` so that it can now handle an integer
+  which will be used as the seconds till the cookie expires.
+* Merge fix for Issue 31, can now handle unicode cache keys.
 * Add ``key_length`` option for cache regions, and for keyword args passed
   into the cache system. Cache keys longer than this will be SHA'd.
 * added runtime beaker.__version__

File beaker/docs/conf.py

View file
  • Ignore whitespace
 # built documents.
 #
 # The short X.Y version.
-version = '1.5.4'
+version = '1.6'
 # The full version, including alpha/beta/rc tags.
-release = '1.5.4'
+release = '1.6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

File beaker/docs/configuration.rst

View file
  • Ignore whitespace
 For example, to configure the ``cookie_expires`` option for Beaker sessions
 below, an appropriate entry in a `Pylons`_ INI file would be::
 
-    # Ironically, setting cookie_expires = true causes Beaker to omit the
+    # Setting cookie_expires = true causes Beaker to omit the
     # expires= field from the Set-Cookie: header, signaling the cookie 
     # should be discarded when the browser closes.
     beaker.session.cookie_expires = true
 
     Defaults to False.
 
-cookie_expires (**optional**, bool, datetime, timedelta)
+cookie_expires (**optional**, bool, datetime, timedelta, int)
     Determines when the cookie used to track the client-side of the session
     will expire. When set to a boolean value, it will either expire at the
     end of the browsers session, or never expire.
 
     Setting to a datetime forces a hard ending time for the session (generally
     used for setting a session to a far off date).
+    
+    Setting to an integer will result in the cookie being set to expire in
+    that many seconds. I.e. a value of ``300`` will result in the cookie being
+    set to expire in 300 seconds.
 
     Defaults to never expiring.
 

File beaker/util.py

View file
  • Ignore whitespace
         ('lock_dir', (str, types.NoneType), "lock_dir must be a string referring to a "
          "directory."),
         ('type', (str, types.NoneType), "Session type must be a string."),
-        ('cookie_expires', (bool, datetime, timedelta), "Cookie expires was "
-         "not a boolean, datetime, or timedelta instance."),
+        ('cookie_expires', (bool, datetime, timedelta, int), "Cookie expires was "
+         "not a boolean, datetime, int, or timedelta instance."),
         ('cookie_domain', (str, types.NoneType), "Cookie domain must be a "
          "string."),
         ('id', (str,), "Session id must be a string."),
         ('webtest_varname', (str, types.NoneType), "Session varname must be "
          "a string."),
     ]
-    return verify_rules(params, rules)
+    opts = verify_rules(params, rules)
+    cookie_expires = opts.get('cookie_expires')
+    if cookie_expires and isinstance(cookie_expires, int):
+        opts['cookie_expires'] = timedelta(seconds=cookie_expires)
+    return opts
 
 
 def coerce_cache_params(params):