import uuid from manifold.util.singleton import Singleton from myslice.settings import logger # the key attached to the session object, where we store # the uuid attached to that session in this cache cache_key = 'cached_uuid' class _SessionExtension(object): """ This object holds all the data we need to attach to a django session object """ def __init__(self): self.metadata = None self.auth = None def __repr__(self): result = " {}".format(k,v)) if cache_key not in session: return cached_uuid = session[cache_key] if cached_uuid not in self: return extension = self[cached_uuid] logger.debug("SessionCache: found extension {}".format(extension)) logger.debug("SessionCache: ----------") @staticmethod def _debug_session(session): result = "" result += "{} x {}".format(session, session.keys()) if cache_key in session: result += " <{} = {}>".format(cache_key, session[cache_key]) return result