[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - ZopePublication.py:1.1.2.13
Chris McDonough
chrism@zope.com
Fri, 30 Nov 2001 14:59:46 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv27401
Modified Files:
Tag: Zope-3x-branch
ZopePublication.py
Log Message:
Added context wrapping of returned objects to traverseName and getDefaultTraversal.
=== Zope3/lib/python/Zope/App/ZopePublication/ZopePublication.py 1.1.2.12 => 1.1.2.13 ===
from Zope.Publisher.mapply import mapply
from Zope.Publisher.Exceptions import Retry
+from Zope.ContextWrapper import wrapper
from types import StringType
-
class RequestContainer:
# TODO: add security assertion declaring access to REQUEST
@@ -79,7 +79,7 @@
pass
def traverseName(self, request, ob, name, check_auth=1):
- raise NotImplemented(
+ raise NotImplementedError(
'This method must be overridden.'
)
@@ -133,16 +133,23 @@
def traverseName(self, request, ob, name, check_auth=1):
if IBrowserPublisher.isImplementedBy(ob):
- return ob.browser_traverse(request, name)
+ ob2 = ob.browser_traverse(request, name)
+ else:
+ adapter = getPresentation(ob, '_traverse', IBrowserPublisher)
+ if adapter is not None:
+ ob2 = adapter.browser_traverse(request, name)
+ else:
+ raise NotFound(ob, name, request)
+
+ wrapped = wrapper.Wrapper(ob2, ob)
+ d = wrapper.getdictcreate(wrapped)
+ d['name'] = name
+ return wrapped
- adapter = getPresentation(ob, '_traverse', IBrowserPublisher)
- if adapter is not None:
- return adapter.browser_traverse(request, name)
-
raise NotFound(ob, name, request)
def getDefaultTraversal(self, request, ob):
- r = (ob, None)
+ r = _marker = []
if IBrowserPublisher.isImplementedBy(ob):
r = ob.browser_default(request)
@@ -150,5 +157,13 @@
adapter = getPresentation(ob, '_traverse', IBrowserPublisher, None)
if adapter is not None:
r = adapter.browser_default(request)
- return r
-
+ if r is _marker:
+ return (ob, None)
+ else:
+ wrapped = wrapper.Wrapper(r[0], ob)
+ d = wrapper.getdictcreate(wrapped)
+ # the following may need to be fixed, as this component
+ # does assert a name, though we have no way of
+ # getting it here - chrism
+ d['name'] = ''
+ return (wrapped, None)