[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/session/ Merge from 3.3 branch:

Philipp von Weitershausen philikon at philikon.de
Thu Aug 31 17:01:07 EDT 2006


Log message for revision 69906:
  Merge from 3.3 branch:
  
   Log message for revision 69904:
    Update session docs to match reality
  
   Log message for revision 69905:
    Make registration of adapters easier from Python code by usiing an adapts()
    declaration.  Remove redundant info from ZCML subsequently.
  
  

Changed:
  U   Zope3/trunk/src/zope/app/session/configure.zcml
  U   Zope3/trunk/src/zope/app/session/design.txt
  U   Zope3/trunk/src/zope/app/session/session.py

-=-
Modified: Zope3/trunk/src/zope/app/session/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/session/configure.zcml	2006-08-31 20:54:52 UTC (rev 69905)
+++ Zope3/trunk/src/zope/app/session/configure.zcml	2006-08-31 21:01:06 UTC (rev 69906)
@@ -5,23 +5,18 @@
     >
     
   <adapter
-      for="zope.publisher.interfaces.IRequest"
-      provides=".interfaces.IClientId"
       factory=".session.ClientId"
       permission="zope.Public" 
       />
 
   <adapter
-      for="zope.publisher.interfaces.IRequest"
-      provides=".interfaces.ISession"
       factory=".session.Session"
       permission="zope.Public"
       />
 
   <adapter
-      for="zope.publisher.interfaces.IRequest"
-      provides="zope.traversing.interfaces.IPathAdapter"
       factory=".session.Session"
+      provides="zope.traversing.interfaces.IPathAdapter"
       name="session"
       />
 

Modified: Zope3/trunk/src/zope/app/session/design.txt
===================================================================
--- Zope3/trunk/src/zope/app/session/design.txt	2006-08-31 20:54:52 UTC (rev 69905)
+++ Zope3/trunk/src/zope/app/session/design.txt	2006-08-31 21:01:06 UTC (rev 69906)
@@ -115,34 +115,32 @@
 
 Application code will merely adapt request objects to a session data
 interface.  Initially, we will define the session data interface
-`IPersistentSessionData'. `IPersistentSessionData` provides a mapping
-interface. Keys in the mapping are application identifiers. Values are
-persistent mapping objects.
+``ISession``.  It provides a mapping interface. Keys in the mapping
+are application identifiers. Values are persistent mapping objects.
 
 Application code that wants to get object session data for a request
-adapts the request to `IPersistentSessionData`::
+adapts the request to ``ISession``::
 
-  data = IPersistentSessionData(request)[appkey]
+  appkey = "mycorp.actionplan"
+  data = ISession(request)[appkey]
 
-where `appkey` is a dotted name that identifies the application, such
-as ``zope.app.actionplan``.  Given the session data, the application
-can then store data in it::
+where ``appkey`` is a dotted name that identifies the application.
+Given the session data, the application can then store data in it::
 
   data['original'] = original_actions
   data['new'] = new_actions
 
 From ZPT, you can access session data using adapter syntax::
 
-  request*PersistentSession
+  request/session:key
 
-So, for example, to access the `old` key for the session data for the
-sample key above:
+So, for example, to access the ``old`` key for the session data for
+the sample key above:
 
-  request*PersistentSession/zope.app.actionplan/old
+  request/session:mycorp.actionplan/old
 
 In this example, the data for an aplication key was a mapping object.
 The semantics of a session data for a particular application key are
-determined by the session data type interface.
-`IPersistentSessionData` defines the application data to be a mapping
-object by default.  Other data interfaces could specify different
-bahavior.
+determined by the session data type interface.  ``ISession`` defines
+the application data to be a mapping object by default.  Other data
+interfaces could specify different bahavior.

Modified: Zope3/trunk/src/zope/app/session/session.py
===================================================================
--- Zope3/trunk/src/zope/app/session/session.py	2006-08-31 20:54:52 UTC (rev 69905)
+++ Zope3/trunk/src/zope/app/session/session.py	2006-08-31 21:01:06 UTC (rev 69906)
@@ -28,8 +28,9 @@
 
 from zope import schema
 from zope.interface import implements
-from zope.component import getUtility
+from zope.component import getUtility, adapts
 from zope.component.interfaces import ComponentLookupError
+from zope.publisher.interfaces import IRequest
 from zope.annotation.interfaces import IAttributeAnnotatable
 
 from interfaces import \
@@ -62,6 +63,7 @@
 
     """
     implements(IClientId)
+    adapts(IRequest)
 
     def __new__(cls, request):
         return str.__new__(
@@ -263,6 +265,8 @@
 class Session(object):
     """See zope.app.session.interfaces.ISession"""
     implements(ISession)
+    adapts(IRequest)
+
     def __init__(self, request):
         self.client_id = str(IClientId(request))
 



More information about the Zope3-Checkins mailing list