[Zope-Checkins] CVS: Zope/lib/python/Products/Sessions - BrowserIdManager.py:1.6 SessionDataManager.py:1.12 SessionInterfaces.py:1.7 __init__.py:1.5

Chris McDonough chrism@zope.com
Wed, 21 Nov 2001 17:36:52 -0500


Update of /cvs-repository/Zope/lib/python/Products/Sessions
In directory cvs.zope.org:/tmp/cvs-serv8883

Modified Files:
	BrowserIdManager.py SessionDataManager.py SessionInterfaces.py 
	__init__.py 
Log Message:
Browser Id Manager is no longer __replaceable__ = UNIQUE, meaning
that other things named browser_id_manager can be created in subfolders.

Wrap transient data objects only in session data manager upon return.
Previously, they had been wrapped also in session data container.

Took out clever traversal error logging code in fear that it would
bloat the ZODB.

Added SessionDataManagerErr and BrowserIdManagerErr to API docs and
made them importable within a PythonScript.

Extended test suite with request-autopopulate tests.



=== Zope/lib/python/Products/Sessions/BrowserIdManager.py 1.5 => 1.6 ===
     security.setPermissionDefault(CHANGE_IDMGR_PERM, ['Manager'])
 
-    __replaceable__ = UNIQUE # singleton for now
-
     __implements__ = (SessionInterfaces.BrowserIdManagerInterface, )
 
     icon = 'misc_/Sessions/idmgr.gif'


=== Zope/lib/python/Products/Sessions/SessionDataManager.py 1.11 => 1.12 ===
 from AccessControl.Role import RoleManager
 from App.Management import Tabs
-from zLOG import LOG, WARNING
+from zLOG import LOG, WARNING, BLATHER
 from AccessControl import ClassSecurityInfo
 import SessionInterfaces
 from SessionPermissions import *
@@ -234,13 +234,13 @@
     def _getSessionDataObject(self, key):
         """ returns new or existing session data object """
         container = self._getSessionDataContainer()
-        ob = container.new_or_existing(key)
+        ob = aq_base(container.new_or_existing(key))
         return ob.__of__(self)
 
     def _getSessionDataObjectByKey(self, key):
         """ returns new or existing session data object """
         container = self._getSessionDataContainer()
-        ob = container.get(key)
+        ob = aq_base(container.get(key))
         if ob is not None:
             return ob.__of__(self)
 
@@ -249,10 +249,8 @@
         transactions for mounted storages. """
         if self.obpath is None:
             err = 'Session data container is unspecified in %s' % self.getId()
-            if DEBUG:
-                LOG('Session Tracking', 0, err)
+            LOG('Session Tracking', WARNING, err)
             raise SessionIdManagerErr, err
-        # return an external data container
         try:
             # This should arguably use restrictedTraverse, but it
             # currently fails for mounted storages.  This might
@@ -260,7 +258,7 @@
             # unrestrictedTraverse is also much faster.
             if DEBUG and not hasattr(self, '_v_wrote_dc_type'):
                 args = string.join(self.obpath, '/')
-                LOG('Session Tracking', 0,
+                LOG('Session Tracking', BLATHER,
                     'External data container at %s in use' % args)
                 self._v_wrote_dc_type = 1
             return self.unrestrictedTraverse(self.obpath)
@@ -303,24 +301,15 @@
     def __init__(self, requestSessionName, sdm):
         self._requestSessionName = requestSessionName
         self._sessionDataManager = sdm
-        self._v_errors=0
 
     def __call__(self, container, request):
-        sdm = self._sessionDataManager.__of__(container)
-        # Yank our session & stuff into request
         try:
+            sdm = self._sessionDataManager.__of__(container)
             session = sdm.getSessionData
-            self._v_errors = 0
         except:
-            errors = getattr(self,"_v_errors", 0)
-            if errors < 4:
-                LOG('Session Tracking', WARNING,'Session automatic traversal '
-                    'failed to get session data', error=sys.exc_info())
-            if errors == 3:
-                LOG('Session Tracking', WARNING, 'Suppressing further '
-                    'automatic session failure error messages on this thread')
-            self._v_errors = errors + 1
-            return    # Throw our hands up but dont fail 
+            msg = 'Session automatic traversal failed to get session data'
+            LOG('Session Tracking', WARNING, msg, error=sys.exc_info())
+            return
         if self._requestSessionName is not None:
             request.set_lazy(self._requestSessionName, session)
 


=== Zope/lib/python/Products/Sessions/SessionInterfaces.py 1.6 => 1.7 ===
         """
 
-


=== Zope/lib/python/Products/Sessions/__init__.py 1.4 => 1.5 ===
 """
 
+import ZODB # this is for testrunner to be happy
 import BrowserIdManager
 import SessionDataManager
+from BrowserIdManager import BrowserIdManagerErr
+from SessionDataManager import SessionDataManagerErr
 
 def initialize(context):
     context.registerClass(
@@ -108,6 +111,20 @@
                       SessionDataManager.constructSessionDataManager)
         )
 
-
     context.registerHelp()
     context.registerHelpTitle("Zope Help")
+    # do module security declarations so folks can use some of the
+    # module-level stuff in PythonScripts
+    #
+    # declare on behalf of Transience too, since ModuleSecurityInfo is too
+    # stupid for me to declare in two places without overwriting one set
+    # with the other. :-(
+    from AccessControl import ModuleSecurityInfo
+    security = ModuleSecurityInfo('Products')
+    security.declarePublic('Sessions')
+    security.declarePublic('Transience')
+    security = ModuleSecurityInfo('Products.Sessions')
+    security.declarePublic('BrowserIdManagerErr')
+    security.declarePublic('SessionDataManagerErr')
+    security = ModuleSecurityInfo('Products.Transience')
+    security.declarePublic('MaxTransientObjectsExceeded')