[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - ZopePublication.py:1.1.2.3
Shane Hathaway
shane@digicool.com
Fri, 16 Nov 2001 14:09:51 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv12078
Modified Files:
Tag: Zope-3x-branch
ZopePublication.py
Log Message:
Made ZopePublication work without ZODB
=== Zope3/lib/python/Zope/App/ZopePublication/ZopePublication.py 1.1.2.2 => 1.1.2.3 ===
import sys
-from ZODB.POSException import ConflictError
+#from ZODB.POSException import ConflictError
from zLOG import LOG, ERROR, INFO
from Zope.Publisher.DefaultPublication import DefaultPublication
@@ -17,6 +17,19 @@
self.REQUEST = request
+class Cleanup:
+ def __init__(self, f):
+ self.__del__ = f
+
+
+try: get_transaction
+except NameError:
+ class get_transaction:
+ def abort(self): pass
+ def begin(self): pass
+ def commit(self): pass
+
+
class ZopePublication (DefaultPublication):
"""
Zope publication specification.
@@ -38,16 +51,21 @@
pass
def getApplication(self, request):
- version = request.get(self.version_cookie, '')
- conn = self.db.open(version)
+ if 0:
+ # Open the database.
+ version = request.get(self.version_cookie, '')
+ conn = self.db.open(version)
- cleanup = Cleanup(conn.close)
- request._hold(cleanup) # Close the connection on request.close()
+ cleanup = Cleanup(conn.close)
+ request._hold(cleanup) # Close the connection on request.close()
- self.openedConnection(conn)
- conn.setDebugInfo(getattr(request, 'environ', None), request.other)
+ self.openedConnection(conn)
+ conn.setDebugInfo(getattr(request, 'environ', None), request.other)
- app = conn.root()[self.root_name]
+ app = conn.root()[self.root_name]
+ else:
+ # shortcut: db is the app.
+ app = self.db
if hasattr(app, '__of__'):
app = app.__of__(RequestContainer(request))
@@ -97,22 +115,23 @@
traversed = request.traversed
if traversed:
context = traversed[-1]
- handler = getExceptionHandler(context, t, request.ptype)
+ #handler = getExceptionHandler(context, t, request.ptype)
+ handler = None # no getExceptionHandler() exists yet.
if handler is not None:
handler(request, exc_info)
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
- response.handleException(exc)
+ response.handleException(exc_info)
return response