def __init__(self): self.mongo = MongoBackend() # Set in the test suite # os.environ['AMON_ENV'] = 'test' if getenv('AMON_ENV', None) == 'test': self.mongo.database = 'amon_test'
'duration': self.duration, 'expires': self.expires, 'ip_address': self.ip_address, 'user_agent': self.user_agent, 'security_model': self.security_model, 'regeneration_interval': self.regeneration_interval, 'next_regeneration': self.next_regeneration } return base64.encodestring(pickle.dumps(dump)) @staticmethod def deserialize(datastring): return pickle.loads(base64.decodestring(datastring)) mongo_backend = MongoBackend() mongo = mongo_backend.get_collection('sessions') class MongoDBSession(BaseSession): """Class implementing the MongoDB based session storage. All sessions are stored in a collection "sessions" in the db you specify in the session_storage setting. The session document structure is following: 'session_id': session ID 'data': serialized session object 'expires': a timestamp of when the session expires, in sec since epoch 'user_agent': self-explanatory An index on session_id is created automatically, on application's init.