comparison MoinMoin/web/session.py @ 4211:dde44d6e24ae

Removed MoinMoin.web.api, use inheritance and abstract classes
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 09 Jul 2008 21:48:04 +0200
parents 988b2b672219
children 42352c0b2a51
comparison
equal deleted inserted replaced
4210:d9de4fa12f23 4211:dde44d6e24ae
10 import time 10 import time
11 11
12 from werkzeug.utils import dump_cookie 12 from werkzeug.utils import dump_cookie
13 from werkzeug.contrib.sessions import FilesystemSessionStore, Session 13 from werkzeug.contrib.sessions import FilesystemSessionStore, Session
14 14
15 from MoinMoin.web.api import ISessionService
16 from MoinMoin import caching 15 from MoinMoin import caching
17 16
18 from MoinMoin import log 17 from MoinMoin import log
19 logging = log.getLogger(__name__) 18 logging = log.getLogger(__name__)
20 19
21 class MoinSession(Session): 20 class MoinSession(Session):
22 """ Compatibility interface to Werkzeug-sessions for old Moin-code. """ 21 """ Compatibility interface to Werkzeug-sessions for old Moin-code. """
23 is_new = property(lambda s: s.new) 22 is_new = property(lambda s: s.new)
24 is_stored = property(lambda s: True) 23 is_stored = property(lambda s: True)
25 24
26 class FileSessionService(object): 25 class SessionService(object):
26 """
27 A session service returns a session object given a request object and
28 provides services like persisting sessions and cleaning up occasionally.
29 """
30 def get_session(self, request):
31 """ Return a session object pertaining to the particular request."""
32 raise NotImplementedError
33
34 def destroy_session(self, request, session):
35 """ Destroy an existing session (make it unusable). """
36 raise NotImplementedError
37
38 def finalize(self, request, session):
39 """
40 Do final modifications to the request and/or session before sending
41 headers and body to the cliebt.
42 """
43 raise NotImplementedError
44
45 class FileSessionService(SessionService):
27 """ 46 """
28 This sample session service stores session information in a temporary 47 This sample session service stores session information in a temporary
29 directory and identifis the session via a cookie in the request/response 48 directory and identifis the session via a cookie in the request/response
30 cycle. 49 cycle.
31 """ 50 """
32
33 __implements__ = (ISessionService, )
34 51
35 def __init__(self, cookie_name='MOIN_SESSION'): 52 def __init__(self, cookie_name='MOIN_SESSION'):
36 self.store = FilesystemSessionStore(session_class=MoinSession) 53 self.store = FilesystemSessionStore(session_class=MoinSession)
37 self.cookie_name = cookie_name 54 self.cookie_name = cookie_name
38 55