[Zope-Checkins] CVS: Zope/lib/python/ZPublisher -
BaseRequest.py:1.53.2.1
Jim Fulton
cvs-admin at zope.org
Tue Nov 25 15:18:17 EST 2003
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv24052/lib/python/ZPublisher
Modified Files:
Tag: Zope-2_8-devel-branch
BaseRequest.py
Log Message:
merged everything but ZODB and ZEO from zodb33-devel-branch
=== Zope/lib/python/ZPublisher/BaseRequest.py 1.53 => 1.53.2.1 ===
--- Zope/lib/python/ZPublisher/BaseRequest.py:1.53 Tue Nov 18 08:17:17 2003
+++ Zope/lib/python/ZPublisher/BaseRequest.py Tue Nov 25 15:17:45 2003
@@ -31,12 +31,19 @@
def manage_property_types(self):
return type_converters.keys()
-except:
+except ImportError:
class RequestContainer:
__roles__=None
def __init__(self,**kw):
for k,v in kw.items(): self.__dict__[k]=v
+try:
+ from AccessControl.ZopeSecurityPolicy import getRoles
+except ImportError:
+ def getRoles(container, name, value, default):
+ return getattr(value, '__roles__', default)
+
+
_marker=[]
class BaseRequest:
"""Provide basic ZPublisher request management
@@ -219,14 +226,14 @@
object=parents[-1]
del parents[:]
- roles = getattr(object, '__roles__', UNSPECIFIED_ROLES)
+ roles = getRoles(None, None, object, UNSPECIFIED_ROLES)
# if the top object has a __bobo_traverse__ method, then use it
# to possibly traverse to an alternate top-level object.
if hasattr(object,'__bobo_traverse__'):
try:
object=object.__bobo_traverse__(request)
- roles =getattr(object, '__roles__', UNSPECIFIED_ROLES)
+ roles = getRoles(None, None, object, UNSPECIFIED_ROLES)
except: pass
if not path and not method:
@@ -281,9 +288,9 @@
entry_name = method
method = 'index_html'
else:
- if (hasattr(object, '__call__') and
- hasattr(object.__call__,'__roles__')):
- roles=object.__call__.__roles__
+ if (hasattr(object, '__call__')):
+ roles = getRoles(object, '__call__', object.__call__,
+ roles)
if request._hacked_path:
i=URL.rfind('/')
if i > 0: response.setBase(URL[:i])
@@ -358,13 +365,9 @@
"The object at %s is not publishable." % URL
)
- r = getattr(subobject, '__roles__', UNSPECIFIED_ROLES)
- if r is not UNSPECIFIED_ROLES:
- roles = r
- elif not got:
- # We got the subobject as an attribute, not an item,
- # so we should check "next to it" for __roles__.
- roles = getattr(object, entry_name+'__roles__', roles)
+ roles = getRoles(
+ object, (not got) and entry_name or None, subobject,
+ roles)
# Promote subobject to object
object=subobject
More information about the Zope-Checkins
mailing list