[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/utilities - session.py:1.5

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Feb 24 09:28:58 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/interfaces/utilities
In directory cvs.zope.org:/tmp/cvs-serv925/app/interfaces/utilities

Modified Files:
	session.py 
Log Message:
Removed zope.utilities.session's mapping interfaces. They duplicated the 
ones in interface.common.mapping; and the ones that did not overlap I just
added to common.mapping. This shoudl have been done like this from the 
beginning. I have no clue why it wasn't.


=== Zope3/src/zope/app/interfaces/utilities/session.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/interfaces/utilities/session.py:1.4	Sun Feb 22 20:02:55 2004
+++ Zope3/src/zope/app/interfaces/utilities/session.py	Tue Feb 24 09:28:27 2004
@@ -11,56 +11,32 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Interfaces for session service."""
+"""Interfaces for session service.
 
+$Id$
+"""
 import re
 from zope.interface import Interface
+from zope.interface.common.mapping import IMapping, IReadMapping, IWriteMapping
 from zope import schema
 from zope.app.interfaces.container import IContainer
 from zope.app.i18n import ZopeMessageIDFactory as _
 
-# XXX: These mapping interfaces should probably live somewhere like 
-# zope.interface.common.mapping, but there are already similar but less
-# useful ones defined there.
-class IReadMapping(Interface):
-    ''' Mapping methods for retrieving data '''
-    def __getitem__(key): 'Return a value'
-    def __contains__(key): 'True if there is a value for key'
-    def get(key, default=None):
-        'Return a value, or default if key not found'
-
-class IWriteMapping(Interface):
-    ''' Mapping methods for changing data '''
-    def __delitem__(key): 'Delete a value'
-    def __setitem__(key): 'Set a value'
-
-class IIterableMapping(Interface):
-    ''' Mapping methods for listing keys and values ''' 
-    def __len__(key): 'Number of items in the IMapping'
-    def __iter__(): 'Iterate over all the keys'
-    def keys(): 'Return a sequence of the keys'
-    def items(): 'Return a sequence of the (key, value) tuples'
-    def values(): 'Return a sequence of the values'
-
-class IFullMapping(IReadMapping, IWriteMapping, IIterableMapping):
-    ''' Full mapping interface '''
-
 
 class IBrowserIdManager(Interface):
-    ''' Manages sessions - fake state over multiple browser requests. '''
+    """Manages sessions - fake state over multiple browser requests."""
 
     def getBrowserId(request):
-        ''' Return the IBrowserId for the given request.
-
-            If the request doesn't have an attached sessionId a new one will
-            be generated.
-
-            This will do whatever is possible to do the HTTP request to ensure
-            the session id will be preserved. Depending on the specific
-            method, further action might be necessary on the part of the user.
-            See the documentation for the specific implementation and its
-            interfaces.
-        '''
+        """Return the IBrowserId for the given request.
+        
+        If the request doesn't have an attached sessionId a new one will be
+        generated.
+
+        This will do whatever is possible to do the HTTP request to ensure the
+        session id will be preserved. Depending on the specific method,
+        further action might be necessary on the part of the user.  See the
+        documentation for the specific implementation and its interfaces.
+        """
 
 
     """ XXX: Want this
@@ -71,7 +47,7 @@
 
 
 class ICookieBrowserIdManager(IBrowserIdManager):
-    ''' Manages sessions using a cookie '''
+    """Manages sessions using a cookie"""
 
     namespace = schema.TextLine(
             title=_('Cookie Name'),
@@ -101,19 +77,25 @@
 
 
 class IBrowserId(Interface):
-    ''' A unique ID representing a session '''
-    def __str__(): '''as a unique ASCII string'''
+    """A unique ID representing a session"""
+
+    def __str__():
+        """As a unique ASCII string"""
 
 
 class ISessionDataContainer(IReadMapping, IWriteMapping):
-    ''' Stores data objects for sessions. The object implementing this
-        interface is responsible for expiring data as it feels appropriate.
+    """Stores data objects for sessions.
+
+    The object implementing this interface is responsible for expiring data as
+    it feels appropriate.
 
-        Used like:
-            session_data_container[browser_id][product_id][key] = value
+    Used like::
+
+      session_data_container[browser_id][product_id][key] = value
+
+    Attempting to access a key that does not exist will raise a KeyError.
+    """
 
-        Attempting to access a key that does not exist will raise a KeyError.
-    '''
     timeout = schema.Int(
             title=_(u"Timeout"),
             description=_(
@@ -135,13 +117,16 @@
             )
 
 
-class ISession(IFullMapping):
-    ''' To access bits of data within an ISessionDataContainer, we
-        need to know the browser_id, the product_id, and the actual key.
-        An ISession is a wrapper around an ISessionDataContainer that
-        simplifies this by storing the browser_id and product_id enabling
-        access using just the key.
-    '''
+class ISession(IMapping):
+    """A session object that keeps the state of the user.
+
+    To access bits of data within an ISessionDataContainer, we
+    need to know the browser_id, the product_id, and the actual key.
+    An ISession is a wrapper around an ISessionDataContainer that
+    simplifies this by storing the browser_id and product_id enabling
+    access using just the key.
+    """
+
     def __init__(session_data_container, browser_id, product_id):
-        ''' Construct an ISession '''
+        """Construct an ISession"""
 




More information about the Zope3-Checkins mailing list