Dashboard > Beaker > Home
  Beaker Log In | Sign Up   View a printable version of the current page.  
  Home
Added by Ben Bangert, last edited by Duncan MacKenzie on Mar 22, 2008  (view change) show comment
Labels: 

About Beaker

Beaker is a caching library that includes Session and Cache objects built on Myghty's Container API used in MyghtyUtils. WSGI middleware is also included to manage Session objects and signed cookies.

Beaker caching is implemented with namespaces allowing one to store not only any Python data that can be pickled, but also multiple versions of it by using multiple keys for a single piece of data under a namespace.

Many thanks to Mike Bayer for his excellent work on Myghty and MyghtyUtils

Key features

  • Fast, robust performance
  • Multiple reader/single writer lock system to avoid duplicate simultaneous cache creation
  • Cache back-ends include dbm, file, memory, memcached, and database (Using SQLAlchemy for multiple-db vendor support)
  • Signed cookies to prevent session hijacking/spoofing
  • Cookie-only sessions to remove the need for a db or file backend (ideal for clustered systems)
  • Extensible Container object to support new back-ends
  • Caches can be divided into namespaces (to represent templates, objects, etc.) then keyed for different copies
  • Create functions for automatic call-backs to create new cache copies after expiration
  • Fine-grained toggling of back-ends, keys, and expiration per Cache object

Download

Beaker can be installed via setuptools:

1
$ sudo easy_install Beaker

Or from source with Mercurial:

1
hg clone https://www.knowledgetap.com/hg/beaker/

View the Beaker repository

Documentation

Sample Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from beaker.middleware import SessionMiddleware

def your_wsgi_app(environ, start_response):
    session = environ['beaker.session']
    if not session.has_key('value'):
        session['value'] = 0
    session['value'] += 1
    session.save()
    start_response('200 OK', [('Content-type', 'text/plain')])
    return ['The current value is: %d' % session['value']]

# Setup your WSGI app to be wrapped in
wsgiapp = your_wsgi_app
# Wrap our app with the session, use a signed cookie named 'mysession'
wsgiapp = SessionMiddleware(wsgiapp, key='mysession', secret='randomsecret')

could someone update the "Sample Usage" section to reflect a pylons app, along with the appropriate filenames?

Posted by jonathan at Mar 06, 2008 23:09 | Permalink
Site running on a free Atlassian Confluence Open Source Project License granted to Pylons. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.3.3 Build:#645 Feb 13, 2007) - Bug/feature request - Contact Administrators