def __setitem__(self, session_id, session): """(session_id : string, session : Session) Store 'session' in the session manager under 'session_id'. """ SessionManager.__setitem__(self, session_id, session) session.save()
def __init__(self, root_namespace, config=None, session_mgr=None): from quixote.session import SessionManager Publisher.__init__(self, root_namespace, config) if session_mgr is None: self.session_mgr = SessionManager() else: self.session_mgr = session_mgr
def __init__(self): sessions = PersistentDict() SessionManager.__init__( self, session_class=PersistentSession, session_mapping=sessions, )
def __init__(self, session_class=None, session_mapping=None): if not mod_py_sess_factory.has_key(session_class): ModPySession.setSessionClass(session_class) mod_py_sess_factory[session_class] = copy.copy(ModPySession) klass = mod_py_sess_factory.get(session_class) SessionManager.__init__(self, session_class=klass, session_mapping=session_mapping)
def publish(self): if issubclass(self.__Publisher, SessionPublisher): create_pub = lambda: self.__Publisher( self, SessionManager(self.__Session, self.__session_mapping)) else: create_pub = lambda: self.__Publisher(self) self.__server.run(create_pub, '', self.__port)
def create_publisher(): """ Create a publisher for TwillTest, with session management added on. """ session_manager = SessionManager(session_class=AlwaysSession) return Publisher(TwillTest(), session_manager=session_manager)
class SessionPublisher(Publisher): def __init__(self, root_namespace, config=None, session_mgr=None): from quixote.session import SessionManager Publisher.__init__(self, root_namespace, config) if session_mgr is None: self.session_mgr = SessionManager() else: self.session_mgr = session_mgr def set_session_manager(self, session_mgr): self.session_mgr = session_mgr def start_request(self, request): # Get the session object and stick it onto the request request.session = self.session_mgr.get_session(request) request.session.start_request(request) def finish_successful_request(self, request): if request.session is not None: request.session.finish_request(request) self.session_mgr.maintain_session(request, request.session) self.session_mgr.commit_changes(request.session) def finish_interrupted_request(self, request, exc): output = Publisher.finish_interrupted_request(self, request, exc) # commit the current transaction so that any changes to the # session objects are saved and are visible on the next HTTP # hit. Remember, AccessError is a subclass of PublishError, # so this code will be run for both typos in the URL and for # the user not being logged in. # # The assumption here is that the UI code won't make changes # to the core database before checking permissions and raising # a PublishError; if you must do this (though it's hard to see # why this would be necessary), you'll have to abort the # current transaction, make your session changes, and then # raise the PublishError. # # XXX We should really be able to commit session changes and # database changes separately, but that requires ZODB # incantations that we currently don't know. self.session_mgr.commit_changes(request.session) return output def finish_failed_request(self, request): if self.session_mgr: self.session_mgr.abort_changes(request.session) return Publisher.finish_failed_request(self, request)
def create_publisher(): return Publisher(RootDirectory(), session_manager=SessionManager(session_class=DemoSession), display_exceptions='plain')
def start_request(self, modpython_request): self.t0 = time.time() self.modpython_request = modpython_request SessionManager.start_request(self)
def __init__ (self, context): SessionManager.__init__(self, SqlQuixoteSession, SqlTableMap(context)) self.context = context
def create_publisher(): return CodePublisher(controllers, session_mgr=SessionManager())
def __init__(self): sessions = PersistentDict() SessionManager.__init__(self, session_class=PersistentSession, session_mapping=sessions)
def make_publisher(self): return self.Publisher(self.root, session_manager=SessionManager( self.Session, self.session_mapping))
def __init__(self): cxn = db.get_cxn() SessionManager.__init__(self, SqlQuixoteSession, SqlTableMap(cxn))