Пример #1
0
    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()
Пример #2
0
 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
Пример #3
0
 def __init__(self):
     sessions = PersistentDict()
     SessionManager.__init__(
         self,
         session_class=PersistentSession,
         session_mapping=sessions,
     )
Пример #4
0
    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)
Пример #5
0
 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
Пример #6
0
 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)
Пример #7
0
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)
Пример #8
0
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)
Пример #9
0
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)
Пример #10
0
def create_publisher():
    return Publisher(RootDirectory(),
                     session_manager=SessionManager(session_class=DemoSession),
                     display_exceptions='plain')
Пример #11
0
 def start_request(self, modpython_request):
     self.t0 = time.time()
     self.modpython_request = modpython_request
     SessionManager.start_request(self)
Пример #12
0
 def __init__ (self, context):
     SessionManager.__init__(self, SqlQuixoteSession, SqlTableMap(context))
     self.context = context
Пример #13
0
Файл: web.py Проект: banjin/code
def create_publisher():
    return CodePublisher(controllers,
                         session_mgr=SessionManager())
Пример #14
0
 def __init__(self):
     sessions = PersistentDict()
     SessionManager.__init__(self,
                             session_class=PersistentSession,
                             session_mapping=sessions)
Пример #15
0
 def make_publisher(self):
     return self.Publisher(self.root,
                           session_manager=SessionManager(
                               self.Session, self.session_mapping))
Пример #16
0
 def __init__(self):
     cxn = db.get_cxn()
     SessionManager.__init__(self, SqlQuixoteSession, SqlTableMap(cxn))