[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - PublicationTraverse.py:1.1.2.3 Traversers.py:1.1.2.11 ZopePublication.py:1.1.2.30
Jim Fulton
jim@zope.com
Tue, 26 Mar 2002 16:26:26 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv7731/Zope/App/ZopePublication
Modified Files:
Tag: Zope-3x-branch
PublicationTraverse.py Traversers.py ZopePublication.py
Log Message:
Merged the publication refactoring branch into the main branch.
Also renamed:
browser_reaverse -> publishTraverse
browser_default -> browserDefault
=== Zope3/lib/python/Zope/App/ZopePublication/PublicationTraverse.py 1.1.2.2 => 1.1.2.3 ===
if IBrowserPublisher.isImplementedBy(ob):
- ob2 = ob.browser_traverse(request, nm)
+ ob2 = ob.publishTraverse(request, nm)
else:
adapter = getRequestView(ob, '_traverse', request, self # marker
)
if adapter is not self:
- ob2 = adapter.browser_traverse(request, nm)
+ ob2 = adapter.publishTraverse(request, nm)
else:
raise NotFound(ob, name, request)
=== Zope3/lib/python/Zope/App/ZopePublication/Traversers.py 1.1.2.10 => 1.1.2.11 ===
self.target = target
- def browser_default(self, request):
+ def browserDefault(self, request):
#XXX: (hack), we really need this to be component
# specific.
ob = self.target
@@ -34,7 +34,7 @@
view_uri = "%s;view" % view_name
return ob, (view_uri,)
- def browser_traverse(self, request, name):
+ def publishTraverse(self, request, name):
""" """
# TODO: Look for default view
ob = self.target
=== Zope3/lib/python/Zope/App/ZopePublication/ZopePublication.py 1.1.2.29 => 1.1.2.30 ===
-class ZopePublication(DefaultPublication):
+class ZopePublication(PublicationTraverse, DefaultPublication):
"""Base Zope publication specification."""
version_cookie = 'Zope-Version'
@@ -76,7 +76,7 @@
conn = self.db.open(version)
cleanup = Cleanup(conn.close)
- request._hold(cleanup) # Close the connection on request.close()
+ request.hold(cleanup) # Close the connection on request.close()
self.openedConnection(conn)
## conn.setDebugInfo(getattr(request, 'environ', None), request.other)
@@ -93,9 +93,6 @@
# Call __before_publishing_traverse__ hooks
pass
- def traverseName(self, request, ob, name, check_auth=1):
- raise NotImplementedError('This method must be overridden.')
-
def getDefaultTraversal(self, request, ob):
return ob, None
@@ -104,7 +101,7 @@
pass
def callObject(self, request, ob):
- return mapply(ob, request.args, request)
+ return mapply(ob, request.getPositionalArguments(), request)
def afterCall(self, request):
get_transaction().commit()
@@ -121,18 +118,22 @@
sm = getSecurityManager()
id = sm.getPrincipal()
prin_reg.unauthorized(id, request) # May issue challenge
- request.response.handleException(exc_info)
+ request.getResponse().handleException(exc_info)
return
- # Look for a component to handle the exception.
- traversed = request.traversed
- if traversed:
- context = traversed[-1]
- #handler = getExceptionHandler(context, t, IBrowserPublisher)
- handler = None # no getExceptionHandler() exists yet.
- if handler is not None:
- handler(request, exc_info)
- return
+
+ # XXX This is wrong. Should use getRequstView:
+ #
+ #
+ # # Look for a component to handle the exception.
+ # traversed = request.traversed
+ # if traversed:
+ # context = traversed[-1]
+ # #handler = getExceptionHandler(context, t, IBrowserPublisher)
+ # handler = None # no getExceptionHandler() exists yet.
+ # if handler is not None:
+ # handler(request, exc_info)
+ # return
# Convert ConflictErrors to Retry exceptions.
if retry_allowed and isinstance(exc_info[1], ConflictError):
@@ -143,7 +144,8 @@
raise Retry
# Let the response handle it as best it can.
- response = request.response
+ # XXX Is this what we want in the long term?
+ response = request.getResponse()
response.handleException(exc_info)
return
finally:
@@ -151,37 +153,6 @@
exc_info = 0
-class BrowserPublication(PublicationTraverse, ZopePublication):
- """Web browser (HTTP) publication handling."""
-
-
def _parameterSetskin(self, pname, pval, request):
request.setViewSkin(pval)
-
- def getDefaultTraversal(self, request, ob):
-
- r = ()
-
- if IBrowserPublisher.isImplementedBy(ob):
- r = ob.browser_default(request)
- else:
- adapter = getRequestView(ob, '_traverse', request , None)
- if adapter is not None:
- r = adapter.browser_default(request)
- else:
- return (ob, None)
-
- if r[0] is ob: return r
-
- wrapped = wrapper.Wrapper(r[0], ob, name=None)
- getSecurityManager().validate(None, wrapped)
- return (wrapped, r[1])
-
- def afterTraversal(self, request, ob):
- request_get = request.get
- T=get_transaction()
- T.note(request_get('PATH_INFO'))
- auth_user=request_get('AUTHENTICATED_USER',None)
- if auth_user is not None:
- T.setUser(auth_user, request_get('AUTHENTICATION_PATH'))