Permalink
Browse files

change to accept being passed an memcache object, such as a MemcacheP…

…ool to manage connections better
  • Loading branch information...
joerussbowman committed May 31, 2010
1 parent 7ea154d commit 05d611ef11cdb1bf6ad750cbd29eee15ac244e57
Showing with 9 additions and 2 deletions.
  1. +9 −2 sessions/__init__.py
View
@@ -28,14 +28,21 @@ def __init__(self, cookie_path=settings.session["DEFAULT_COOKIE_PATH"],
session_token_ttl=settings.session["SESSION_TOKEN_TTL"],
session_expire_time=settings.session["SESSION_EXPIRE_TIME"],
memcache_url=settings.session["MEMCACHE_URL"],
- req_obj = False):
+ req_obj = False,
+ mc = None):
"""
__init__ loads the session, checking the browser for a valid session
token. It will either validate the session and/or create a new one
if necessary.
"""
- self.mc = memcache.Client(memcache_url, debug=0)
+ # accept being passed a memcache object, which can be
+ # a MemcachePool, as found here
+ # http://jehiah.cz/download/MemcachePool.py.txt
+ if mc is None:
+ self.mc = memcache.Client(memcache_url, debug=0)
+ else:
+ self.mc = mc
# If session is being used on this page view, then go ahead
# and make the page not cacheable. This makes sure the user

0 comments on commit 05d611e

Please sign in to comment.