Skip to content
Browse files

Documentation for 0.2 and refactoring

  • Loading branch information...
1 parent ae96cc2 commit d621e1aec690066ff5a79347bbfca9cf2f69b683 @diogobaeder committed Oct 29, 2011
Showing with 13 additions and 11 deletions.
  1. +8 −7 pycket/driver.py
  2. +5 −4 pycket/session.py
View
15 pycket/driver.py
@@ -1,8 +1,16 @@
+'''
+This module is for internal use, only. It contains datastore drivers to be used
+with the session and notification managers.
+'''
from copy import copy
import pickle
class Driver(object):
+ EXPIRE_SECONDS = 24 * 60 * 60
+
+ client = None
+
def _to_dict(self, raw_session):
if raw_session is None:
return {}
@@ -27,14 +35,11 @@ def set(self, session_id, session):
class RedisDriver(Driver):
- EXPIRE_SECONDS = 24 * 60 * 60
DEFAULT_STORAGE_IDENTIFIERS = {
'db_sessions': 0,
'db_notifications': 1,
}
- client = None
-
def __init__(self, settings):
self.settings = settings
@@ -48,10 +53,6 @@ def _create_client(self):
class MemcachedDriver(Driver):
- EXPIRE_SECONDS = 24 * 60 * 60
-
- client = None
-
def __init__(self, settings):
self.settings = settings
View
9 pycket/session.py
@@ -10,6 +10,7 @@
Supported engines, for now, are:
- Redis
+- Memcache
If you want to change the settings that are passed to the storage client, set a
"storage" dictionary in the "pycket" settings with the intended storage settings
@@ -21,8 +22,8 @@
If you want to change the cookie settings passed to the handler, set a
"cookies" setting in the "pycket" settings with the items you want.
This is also valid for "expires" and "expires_days", which, by default, will be
-None, therefore making the sessions expire on browser close, but, if you set
-them, your custom values will override the default behaviour.
+None, therefore making the sessions expire on browser close, but, if you set one
+of them, your custom value will override the default behaviour.
'''
from uuid import uuid4
@@ -33,8 +34,8 @@
class SessionManager(object):
'''
This is the real class that manages sessions. All session objects are
- persisted in a Redis database, inside db 0.
- After 1 day without changing a session, it's purged from the dataset,
+ persisted in a Redis or Memcache store (depending on your settings).
+ After 1 day without changing a session, it's purged from the datastore,
to avoid it to grow out-of-control.
When a session is started, a cookie named 'PYCKET_ID' is set, containing the

0 comments on commit d621e1a

Please sign in to comment.
Something went wrong with that request. Please try again.