コード例 #1
0
ファイル: basemodel.py プロジェクト: yogaredhat/amonone
    def __init__(self):
        self.mongo = MongoBackend()
        self.db = self.mongo.get_database()

        self.desc = DESCENDING
        self.asc = ASCENDING

        self.collection = None  # Defined in the child models
コード例 #2
0
ファイル: session.py プロジェクト: yogaredhat/amonone
            '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.