changeset 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 d9de4fa12f23
children 1ca179133f01
files MoinMoin/web/api.py MoinMoin/web/contexts.py MoinMoin/web/session.py
diffstat 3 files changed, 21 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/api.py	Wed Jul 09 20:43:29 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - Interface definitions
-
-    Interface definitions for the Request object and associated classes
-    and services.
-
-    @copyright: 2008 MoinMoin:FlorianKrupicka
-    @license: GNU GPL, see COPYING for details.
-"""
-
-class Interface(object):
-    """ An interface (marker class) """
-
-class IContext(Interface):
-    """
-    A context object represents the request in different phases of the
-    request/response cycle, e.g. session setup, page renderin (formatter
-    or parser), XML-RPC, etc.
-    """
-    def become(cls):
-        """ Become another context, based on the given class. """
-
-
-class ISessionService(Interface):
-    """
-    A session service returns a session object given a request object and
-    provides services like persisting sessions and cleaning up occasionally.
-    """
-    def get_session(request):
-        """ Return a session object pertaining to the particular request."""
-
-    def destroy_session(request, session):
-        """ Destroy an existing session (make it unusable). """
-
-    def finalize(request, session):
-        """
-        Do final modifications to the request and/or session before sending
-        headers and body to the cliebt.
-        """
--- a/MoinMoin/web/contexts.py	Wed Jul 09 20:43:29 2008 +0200
+++ b/MoinMoin/web/contexts.py	Wed Jul 09 21:48:04 2008 +0200
@@ -21,7 +21,6 @@
 from MoinMoin.web.request import Request
 from MoinMoin.web.utils import check_spider, UniqueIDGenerator
 from MoinMoin.web.exceptions import Forbidden, SurgeProtection
-from MoinMoin.web.api import IContext
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
@@ -80,7 +79,6 @@
     environ and also keeps track of it's changes.
     """
     __slots__ = ['request', 'environ']
-    __implements__ = (IContext, )
 
     def __init__(self, request):
         assert isinstance(request, Request)
--- a/MoinMoin/web/session.py	Wed Jul 09 20:43:29 2008 +0200
+++ b/MoinMoin/web/session.py	Wed Jul 09 21:48:04 2008 +0200
@@ -12,7 +12,6 @@
 from werkzeug.utils import dump_cookie
 from werkzeug.contrib.sessions import FilesystemSessionStore, Session
 
-from MoinMoin.web.api import ISessionService
 from MoinMoin import caching
 
 from MoinMoin import log
@@ -23,15 +22,33 @@
     is_new = property(lambda s: s.new)
     is_stored = property(lambda s: True)
 
-class FileSessionService(object):
+class SessionService(object):
+    """
+    A session service returns a session object given a request object and
+    provides services like persisting sessions and cleaning up occasionally.
+    """
+    def get_session(self, request):
+        """ Return a session object pertaining to the particular request."""
+        raise NotImplementedError
+
+    def destroy_session(self, request, session):
+        """ Destroy an existing session (make it unusable). """
+        raise NotImplementedError
+
+    def finalize(self, request, session):
+        """
+        Do final modifications to the request and/or session before sending
+        headers and body to the cliebt.
+        """
+        raise NotImplementedError
+
+class FileSessionService(SessionService):
     """
     This sample session service stores session information in a temporary
     directory and identifis the session via a cookie in the request/response
     cycle.
     """
 
-    __implements__ = (ISessionService, )
-
     def __init__(self, cookie_name='MOIN_SESSION'):
         self.store = FilesystemSessionStore(session_class=MoinSession)
         self.cookie_name = cookie_name