[Zope-Checkins] CVS: Zope/lib/python/ZPublisher -
BaseRequest.py:1.51.14.4
Christian Theune
ct at gocept.com
Mon Jan 12 06:32:33 EST 2004
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv9593/lib/python/ZPublisher
Modified Files:
Tag: Zope-2_7-posttraverse
BaseRequest.py
Log Message:
- Final solution for the posttraverse problem.
Posttraverse scripts can now replace the object-to-be-published
(but they don't modify the REQUEST['PUBLISHED'] right now, as
this is intended) by returning something different than None.
=== Zope/lib/python/ZPublisher/BaseRequest.py 1.51.14.3 => 1.51.14.4 ===
--- Zope/lib/python/ZPublisher/BaseRequest.py:1.51.14.3 Fri Oct 17 05:14:51 2003
+++ Zope/lib/python/ZPublisher/BaseRequest.py Mon Jan 12 06:32:32 2004
@@ -10,7 +10,10 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
-__version__='$Revision$'[11:-2]
+""" Basic ZPublisher request management.
+
+$Id$
+"""
from urllib import quote
import xmlrpc
@@ -270,13 +273,13 @@
request['TraversalRequestNameStack'] = path
continue
else:
- method = default_path[0]
- entry_name = method
+ entry_name = default_path[0]
elif (method and hasattr(object,method)
and entry_name != method
and getattr(object, method) is not None):
request._hacked_path=1
entry_name = method
+ method = 'index_html'
else:
if (hasattr(object, '__call__') and
hasattr(object.__call__,'__roles__')):
@@ -285,7 +288,6 @@
i=URL.rfind('/')
if i > 0: response.setBase(URL[:i])
break
- if not entry_name: continue
step = quote(entry_name)
_steps.append(step)
request['URL'] = URL = '%s/%s' % (request['URL'], step)
@@ -445,8 +447,12 @@
# Remove http request method from the URL.
request['URL']=URL
+ result = None
if post_traverse:
- exec_callables(post_traverse)
+ result = exec_callables(post_traverse)
+
+ if result is not None:
+ object = result
return object
@@ -463,9 +469,10 @@
self._held=self._held+(object,)
def exec_callables(callables):
+ result = None
for (f, args) in callables:
try:
- f(*args)
+ result = f(*args)
except (ArithmeticError, AttributeError, FloatingPointError,
IOError, ImportError, IndexError, KeyError,
OSError, OverflowError, TypeError, ValueError,
@@ -478,6 +485,8 @@
LOG('PostTraverse', ERROR,
'Error while invoking hook: "%s"' % `f`,
error=sys.exc_info())
+ if result is not None:
+ return result
def old_validation(groups, request, auth,
roles=UNSPECIFIED_ROLES):
More information about the Zope-Checkins
mailing list