[Zope3-checkins] CVS: Zope3/src/zope/app/services - configure.zcml:1.3 session.py:1.4 test_cookiesessionservice.py:NONE

Steve Alexander steve@cat-box.net
Thu, 26 Dec 2002 14:13:40 -0500


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv23163/app/services

Modified Files:
	configure.zcml session.py 
Removed Files:
	test_cookiesessionservice.py 
Log Message:
Changed the name of the session service from SessionService to Sessions.
Moved test_cookiesessionservice.py to the tests package.
Reformatted session.py to be under 80 chars width.


=== Zope3/src/zope/app/services/configure.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/services/configure.zcml:1.2	Wed Dec 25 09:13:19 2002
+++ Zope3/src/zope/app/services/configure.zcml	Thu Dec 26 14:13:09 2002
@@ -132,7 +132,7 @@
 <!-- Session Templates -->
 
   <serviceType
-      id="SessionService" 
+      id="Sessions" 
       interface="zope.app.interfaces.services.session.ISessionService" />
 
   <content class="zope.app.services.session.CookieSessionService">


=== Zope3/src/zope/app/services/session.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/session.py:1.3	Thu Dec 26 14:01:45 2002
+++ Zope3/src/zope/app/services/session.py	Thu Dec 26 14:13:09 2002
@@ -25,9 +25,11 @@
 from persistence import Persistent
 from persistence.dict import PersistentDict
 from zope.server.http.http_date import build_http_date
+from zope.component import getService
 
 # Sibling imports
-from zope.app.interfaces.services.session import ISessionService, IConfigureSessionService
+from zope.app.interfaces.services.session import ISessionService
+from zope.app.interfaces.services.session import IConfigureSessionService
 
 
 cookieSafeTrans = string.maketrans("+/", "-.")
@@ -40,7 +42,8 @@
 class CookieSessionService(Persistent):
     """Session service implemented using cookies."""
 
-    __implements__ = Persistent.__implements__, ISessionService, IConfigureSessionService
+    __implements__ = (Persistent.__implements__, ISessionService,
+                      IConfigureSessionService)
 
     def __init__(self):
         self.dataManagers = PersistentDict()
@@ -58,19 +61,25 @@
         return s + digestEncode(mac)
 
     def getRequestId(self, request):
-        """Return the sessionId encoded in request or None if it's non-existent."""
+        """Return the sessionId encoded in request or None if it's
+        non-existent."""
         sid = request.cookies.get(self.namespace)
         if sid is None or len(sid) != 54:
             return None
         s, mac = sid[:27], sid[27:]
-        if digestEncode(hmac.new(s, self.secret, digestmod=sha).digest()) != mac:
+        if (digestEncode(hmac.new(s, self.secret, digestmod=sha).digest())
+            != mac):
             return None
         else:
             return sid
 
     def setRequestId(self, request, id):
         """Set cookie with id on request."""
-        request.response.setCookie(self.namespace, id, expires=build_http_date(time.time() + 1800))
+        request.response.setCookie(
+                self.namespace,
+                id,
+                expires=build_http_date(time.time() + 1800)
+                )
 
 
     #####################################
@@ -92,7 +101,8 @@
 
     def registerDataManager(self, name, dataManager):
         if self.dataManagers.has_key(name):
-            raise ValueError, "DataManager already registered with name %r" % name
+            raise ValueError(
+                    "DataManager already registered with name %r" % name)
         self.dataManagers[name] = dataManager
 
     def unregisterDataManager(self, name):
@@ -102,6 +112,6 @@
 
 def getSessionDataObject(context, request, name):
     """Get data object from appropriate ISessionDataManager."""
-    service = getService(context, "SessionService")
+    service = getService(context, "Sessions")
     sid = service.getSessionId(request)
     return service.getDataManager(name).getDataObject(sid)

=== Removed File Zope3/src/zope/app/services/test_cookiesessionservice.py ===