[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - ZopePublication.py:1.1.2.14
Shane Hathaway
shane@digicool.com
Fri, 30 Nov 2001 15:14:30 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv30767/lib/python/Zope/App/ZopePublication
Modified Files:
Tag: Zope-3x-branch
ZopePublication.py
Log Message:
Fixed ZODB integration
=== Zope3/lib/python/Zope/App/ZopePublication/ZopePublication.py 1.1.2.13 => 1.1.2.14 ===
import sys
+from types import StringType, ClassType
-#from ZODB.POSException import ConflictError
from zLOG import LOG, ERROR, INFO
from Zope.Publisher.Exceptions import NotFound, DebugError
from Zope.ComponentArchitecture import getPresentation
from Zope.Publisher.DefaultPublication import DefaultPublication
from Zope.Publisher.mapply import mapply
from Zope.Publisher.Exceptions import Retry
+
+from ZODB.POSException import ConflictError
+from Zope.App.OFS.RootFolder import RootFolder
from Zope.ContextWrapper import wrapper
-from types import StringType
class RequestContainer:
# TODO: add security assertion declaring access to REQUEST
@@ -44,6 +46,7 @@
version_cookie = 'Zope-Version'
root_name = 'Application'
+ root_class = RootFolder
def __init__(self, db):
# db is a ZODB.DB.DB object.
@@ -67,7 +70,11 @@
self.openedConnection(conn)
conn.setDebugInfo(getattr(request, 'environ', None), request.other)
- app = conn.root()[self.root_name]
+ root = conn.root()
+ app = root.get(self.root_name, None)
+ if app is None:
+ app = self.root_class()
+ root[self.root_name] = app
if hasattr(app, '__of__'):
app = app.__of__(RequestContainer(request))
@@ -79,9 +86,7 @@
pass
def traverseName(self, request, ob, name, check_auth=1):
- raise NotImplementedError(
- 'This method must be overridden.'
- )
+ raise NotImplementedError('This method must be overridden.')
def getDefaultTraversal(self, request, ob):
return ob, None
@@ -113,12 +118,12 @@
return request.response
# Handle special exception types.
-## if isinstance(t, ClassType):
-## if retry_allowed and issubclass(t, ConflictError):
-## LOG('Zope Publication', INFO,
-## 'Competing writes at %s' % request.get('PATH_INFO', '???'),
-## error=sys.exc_info())
-## raise Retry
+ if isinstance(t, ClassType):
+ if retry_allowed and issubclass(t, ConflictError):
+ LOG('Zope Publication', INFO,
+ 'Competing writes at %s' % request.get('PATH_INFO', '???'),
+ error=sys.exc_info())
+ raise Retry
# Let the response handle it as best it can.
response = request.response