Commit ac8f6f41 authored by Chris McDonough's avatar Chris McDonough

Merging from 2.5 branch.

parent 625b85d0
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################ ############################################################################
import re, time, sys import re, time, string, sys
import Globals import Globals
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Acquisition import Implicit, Explicit, aq_base from Acquisition import Implicit, Explicit, aq_base
...@@ -23,6 +23,7 @@ from zLOG import LOG, WARNING, BLATHER ...@@ -23,6 +23,7 @@ from zLOG import LOG, WARNING, BLATHER
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
import SessionInterfaces import SessionInterfaces
from SessionPermissions import * from SessionPermissions import *
from types import StringType
from common import DEBUG from common import DEBUG
from ZPublisher.BeforeTraverse import registerBeforeTraverse, \ from ZPublisher.BeforeTraverse import registerBeforeTraverse, \
unregisterBeforeTraverse unregisterBeforeTraverse
...@@ -150,7 +151,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -150,7 +151,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
'Container path contains characters invalid in a Zope ' 'Container path contains characters invalid in a Zope '
'object path' 'object path'
) )
self.obpath = path.split('/') self.obpath = string.split(path, '/')
elif type(path) in (type([]), type(())): elif type(path) in (type([]), type(())):
self.obpath = list(path) # sequence self.obpath = list(path) # sequence
else: else:
...@@ -160,7 +161,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -160,7 +161,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
def getContainerPath(self): def getContainerPath(self):
""" """ """ """
if self.obpath is not None: if self.obpath is not None:
return '/'.join(self.obpath) return string.join(self.obpath, '/')
return '' # blank string represents undefined state return '' # blank string represents undefined state
def _hasSessionDataObject(self, key): def _hasSessionDataObject(self, key):
...@@ -194,7 +195,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -194,7 +195,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
# be construed as a security hole, albeit a minor one. # be construed as a security hole, albeit a minor one.
# unrestrictedTraverse is also much faster. # unrestrictedTraverse is also much faster.
if DEBUG and not hasattr(self, '_v_wrote_dc_type'): if DEBUG and not hasattr(self, '_v_wrote_dc_type'):
args = '/'.join(self.obpath) args = string.join(self.obpath, '/')
LOG('Session Tracking', BLATHER, LOG('Session Tracking', BLATHER,
'External data container at %s in use' % args) 'External data container at %s in use' % args)
self._v_wrote_dc_type = 1 self._v_wrote_dc_type = 1
...@@ -202,7 +203,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -202,7 +203,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
except: except:
raise SessionDataManagerErr, ( raise SessionDataManagerErr, (
"External session data container '%s' not found." % "External session data container '%s' not found." %
'/'.join(self.obpath) string.join(self.obpath,'/')
) )
security.declareProtected(MGMT_SCREEN_PERM, 'getRequestName') security.declareProtected(MGMT_SCREEN_PERM, 'getRequestName')
...@@ -229,24 +230,33 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -229,24 +230,33 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
self._requestSessionName = None self._requestSessionName = None
if requestSessionName: if requestSessionName:
hook = SessionDataManagerTraverser(requestSessionName, self) hook = SessionDataManagerTraverser(requestSessionName, self.id)
registerBeforeTraverse(parent, hook, 'SessionDataManager', 50) registerBeforeTraverse(parent, hook, 'SessionDataManager', 50)
self._hasTraversalHook = 1 self._hasTraversalHook = 1
self._requestSessionName = requestSessionName self._requestSessionName = requestSessionName
class SessionDataManagerTraverser(Persistent): class SessionDataManagerTraverser(Persistent):
def __init__(self, requestSessionName, sdm): def __init__(self, requestSessionName, sessionDataManagerName):
self._requestSessionName = requestSessionName self._requestSessionName = requestSessionName
self._sessionDataManager = sdm self._sessionDataManager = sessionDataManagerName
def __call__(self, container, request): def __call__(self, container, request, StringType=StringType):
try: try:
sdm = self._sessionDataManager.__of__(container) sdmName = self._sessionDataManager
session = sdm.getSessionData if not isinstance(sdmName, StringType):
# Zopes v2.5.0 - 2.5.1b1 stuck the actual session data
# manager object in _sessionDataManager in order to use
# its getSessionData method. We don't actually want to
# do this, because it's safer to use getattr to get the
# data manager object by name. Using getattr also puts
# the sdm in the right context automatically. Here we
# pay the penance for backwards compatibility:
sdmName = sdmName.id
sdm = getattr(container, sdmName)
getSessionData = sdm.getSessionData
except: except:
msg = 'Session automatic traversal failed to get session data' msg = 'Session automatic traversal failed to get session data'
LOG('Session Tracking', WARNING, msg, error=sys.exc_info()) LOG('Session Tracking', WARNING, msg, error=sys.exc_info())
return return
if self._requestSessionName is not None: if self._requestSessionName is not None:
request.set_lazy(self._requestSessionName, session) request.set_lazy(self._requestSessionName, getSessionData)
...@@ -43,7 +43,7 @@ user. ...@@ -43,7 +43,7 @@ user.
<div class="form-label"> <div class="form-label">
Transient Object Container Path Transient Object Container Path
</div> </div>
<div class="form-help">e.g. '/temp_folder/transient_container'.</div> <div class="form-help">e.g. '/temp_folder/session_data'.</div>
</TD> </TD>
<TD ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="path" SIZE="60" value=""> <INPUT TYPE="TEXT" NAME="path" SIZE="60" value="">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment