[Zope-Checkins] CVS: Packages/ZPublisher -
BaseRequest.py:1.51.2.2.10.1
Sidnei da Silva
sidnei at awkly.org
Mon Oct 4 16:30:14 EDT 2004
Update of /cvs-repository/Packages/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv24107/lib/python/ZPublisher
Modified Files:
Tag: dc-bobo_traverse-branch
BaseRequest.py
Log Message:
Change ZPublisher behavior to catch AttributeError and KeyError on __bobo_traverse__ and then fallback to attribute and item access if such an exception is caught. Added some tests to verify the behavior
=== Packages/ZPublisher/BaseRequest.py 1.51.2.2 => 1.51.2.2.10.1 ===
--- Packages/ZPublisher/BaseRequest.py:1.51.2.2 Mon Nov 17 17:34:19 2003
+++ Packages/ZPublisher/BaseRequest.py Mon Oct 4 16:29:44 2004
@@ -298,15 +298,20 @@
"Object name begins with an underscore at: %s" % URL)
else: return response.forbiddenError(entry_name)
- if hasattr(object,'__bobo_traverse__'):
- subobject=object.__bobo_traverse__(request,entry_name)
- if type(subobject) is type(()) and len(subobject) > 1:
- # Add additional parents into the path
- parents[-1:] = list(subobject[:-1])
- object, subobject = subobject[-2:]
- else:
- try:
+ bobo_got = 0
+ try:
+ if hasattr(object,'__bobo_traverse__'):
+ subobject=object.__bobo_traverse__(request,entry_name)
+ bobo_got = 1
+ if type(subobject) is type(()) and len(subobject) > 1:
+ # Add additional parents into the path
+ parents[-1:] = list(subobject[:-1])
+ object, subobject = subobject[-2:]
+ except (AttributeError, KeyError):
+ pass
+ if not bobo_got:
+ try:
# Note - no_acquire_flag is necessary to support
# things like DAV. We have to make sure
# that the target object is not acquired
@@ -352,7 +357,7 @@
# certain mutable types (dicts, lists) to become publishable
# when they shouldn't be. The following check makes sure that
# the right thing happens in both 2.2.2+ and earlier versions.
-
+
if not typeCheck(subobject):
return response.debugError(
"The object at %s is not publishable." % URL
More information about the Zope-Checkins
mailing list