[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher - BaseRequest.py:1.1.2.18
Jim Fulton
jim@zope.com
Sun, 3 Feb 2002 18:42:08 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher
In directory cvs.zope.org:/tmp/cvs-serv8253
Modified Files:
Tag: Zope-3x-branch
BaseRequest.py
Log Message:
Kapil Thangavelu
refactored traverse to call browser_default multiple times.
=== Zope3/lib/python/Zope/Publisher/BaseRequest.py 1.1.2.17 => 1.1.2.18 ===
Private.
"""
- added_default = 0
+
+ traversal_altered = 0 # flag for adding traversal steps
+ add_steps = None
path_str = self.get('PATH_INFO', '').strip()
to_traverse = self.splitPath(path_str)
@@ -249,36 +251,41 @@
if entry_name:
qstep = pc_quote(entry_name)
quoted_steps.append(qstep)
- if not added_default:
- # Build up the URL to the object, but not
- # to the default traversal.
- self.URL = '%s/%s' % (self.URL, qstep)
- else:
- # The effective URL includes the default traversal.
+
+ if traversal_altered:
+ # The effective URL includes the altered traversal.
+ #import pdb; pdb.set_trace()
e_url = self.effective_url or self.URL
self.effective_url = '%s/%s' % (e_url, qstep)
+ else:
+ # Build up the URL to the object, but not
+ # to the default traversal.
+ self.URL = '%s/%s' % (self.URL, qstep)
subobject = publication.traverseName(
self, object, entry_name)
object = subobject
traversed.append(object)
steps.append(entry_name)
- elif not added_default:
- # Traverse to the default view, if any.
- added_default = 1
+ else:
add_steps = self._request_default
+
+ if add_steps:
+ self._request_default = None
+
if add_steps is None:
object, add_steps = publication.getDefaultTraversal(
self, object)
+
if add_steps:
+ traversal_altered = 1
to_traverse.extend(add_steps)
-
- else:
- # Finished traversal.
- break
-
- if added_default:
- self.response.setBase(self.URL)
+ else:
+ # Finished traversal.
+ break
+
+ if traversal_altered:
+ self.response.setBase(self.effective_url)
self.traversed = tuple(traversed) # No more changes allowed
parents = traversed[:]