[Zope3-checkins] SVN: Zope3/branches/jinty-zodbless/src/zope/app/
Prototype (and probably a little buggy) patch to make it
easier to run zope
Brian Sutherland
jinty at web.de
Thu Apr 5 08:46:29 EDT 2007
Log message for revision 74019:
Prototype (and probably a little buggy) patch to make it easier to run zope
without a ZODB.
This patch is really just to show the design decisions, a lot of work will
follow if there is some consensus that these decisions are correct.
The design decisions are:
* Start moving ZODB specific stuff to a zope.app.zodb package.
* The publication object gets a IRsourceFactory implementing object as it's
first argument (idea stolen from zope.bobo).
* The server startup scripts look for a utility implementing
IApplicationFactory.
The goal is to reduce the steps necessary to run zope without the ZODB to:
* Implement and register an IApplicationFactory utility
* Remove the <zodb> section from zope.conf
Changed:
U Zope3/branches/jinty-zodbless/src/zope/app/appsetup/interfaces.py
U Zope3/branches/jinty-zodbless/src/zope/app/generations/browser/managers.py
U Zope3/branches/jinty-zodbless/src/zope/app/publication/interfaces.py
U Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_browserpublication.py
U Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_http.py
U Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_httpfactory.py
U Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py
U Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py
U Zope3/branches/jinty-zodbless/src/zope/app/server/ftp.py
U Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/server.py
U Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py
U Zope3/branches/jinty-zodbless/src/zope/app/twisted/main.py
U Zope3/branches/jinty-zodbless/src/zope/app/wsgi/README.txt
U Zope3/branches/jinty-zodbless/src/zope/app/zcmlfiles/configure.zcml
A Zope3/branches/jinty-zodbless/src/zope/app/zodb/
A Zope3/branches/jinty-zodbless/src/zope/app/zodb/__init__.py
A Zope3/branches/jinty-zodbless/src/zope/app/zodb/app.py
A Zope3/branches/jinty-zodbless/src/zope/app/zodb/configure.zcml
-=-
Modified: Zope3/branches/jinty-zodbless/src/zope/app/appsetup/interfaces.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/appsetup/interfaces.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/appsetup/interfaces.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -17,6 +17,7 @@
"""
from zope import interface
+from zope.app.publication.interfaces import IResourceFactory
class IDatabaseOpenedEvent(interface.Interface):
@@ -47,5 +48,11 @@
class ProcessStarting(object):
interface.implements(IProcessStartingEvent)
+class IApplicationFactory(IResourceFactory):
-
+ def prepare(self):
+ """Prepare the application object factory.
+
+ This must be called once, after the component architecture
+ has been loaded.
+ """
Modified: Zope3/branches/jinty-zodbless/src/zope/app/generations/browser/managers.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/generations/browser/managers.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/generations/browser/managers.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -33,7 +33,7 @@
def _getdb(self):
# TODO: There needs to be a better api for this
- return self.request.publication.db
+ return self.request.publication.resource_factory.db
def evolve(self):
"""Perform a requested evolution
@@ -51,13 +51,16 @@
We also need to give it a publication with a database:
+ >>> class StubResourceFactory(object):
+ ... pass
>>> class Publication(object):
- ... pass
+ ... def __init__(self):
+ ... self.resource_factory = StubResourceFactory()
>>> request.setPublication(Publication())
>>> from ZODB.tests.util import DB
>>> db = DB()
- >>> request.publication.db = db
+ >>> request.publication.resource_factory.db = db
We need to define some schema managers. We'll define two
using the demo package:
@@ -202,13 +205,16 @@
We also need to give it a publication with a database:
+ >>> class StubResourceFactory(object):
+ ... pass
>>> class Publication(object):
- ... pass
+ ... def __init__(self):
+ ... self.resource_factory = StubResourceFactory()
>>> request.setPublication(Publication())
>>> from ZODB.tests.util import DB
>>> db = DB()
- >>> request.publication.db = db
+ >>> request.publication.resource_factory.db = db
We need to define some schema managers. We'll define two
using the demo package:
Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/interfaces.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/interfaces.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/interfaces.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -118,3 +118,8 @@
"""Return the internal datastructure representing the configured
factories (basically for testing, not for introspection).
"""
+
+class IResourceFactory(interface.Interface):
+
+ def __call__(request):
+ """Return the root application object for the request."""
Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_browserpublication.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_browserpublication.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_browserpublication.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -13,7 +13,7 @@
##############################################################################
"""Browser Publication Tests
-$Id: test_browserpublication.py 38357 2005-09-07 20:14:34Z srichter $
+$Id$
"""
import unittest
@@ -248,7 +248,7 @@
self.assertEqual(app, applicationControllerRoot)
def testHEADFuxup(self):
- pub = self.klass(None)
+ pub = self.klass(self.db)
class User(object):
id = 'bob'
@@ -303,7 +303,7 @@
factoryRegistry.register('HEAD', '*', 'BROWSER', 10, BrowserFactory())
def testGetBackSamePublication(self):
- factory = HTTPPublicationRequestFactory(db=None)
+ factory = HTTPPublicationRequestFactory(db=self.db)
args = (StringIO(''), {})
self.assert_(id(factory(*args).publication) ==
id(factory(*args).publication))
Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_http.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_http.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_http.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -22,10 +22,14 @@
from zope.publisher.http import HTTPRequest
from zope.publisher.interfaces.http import IHTTPRequest
+from zope.app.publication.interfaces import IResourceFactory
import zope.app.publication.http
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
+class StubResourceFactory:
+ implements(IResourceFactory)
+
class I(Interface):
pass
@@ -46,7 +50,8 @@
# Note that zope publication tests cover all of the code but callObject
def test_callObject(self):
- pub = zope.app.publication.http.HTTPPublication(None)
+ stub = StubResourceFactory()
+ pub = zope.app.publication.http.HTTPPublication(stub)
request = HTTPRequest(StringIO(''), {})
request.method = 'SPAM'
Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_httpfactory.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_httpfactory.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_httpfactory.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -13,7 +13,7 @@
##############################################################################
"""Tests for the HTTP Publication Request Factory.
-$Id: test_httpfactory.py 38357 2005-09-07 20:14:34Z srichter $
+$Id$
"""
from unittest import TestCase, TestSuite, main, makeSuite
@@ -44,11 +44,15 @@
def setPublication(self, pub):
self.pub = pub
+class StubResourceFactory:
+ interface.implements(interfaces.IResourceFactory)
+
class Test(PlacelessSetup, TestCase):
def setUp(self):
super(Test, self).setUp()
- self.__factory = HTTPPublicationRequestFactory(None)
+ stub = StubResourceFactory()
+ self.__factory = HTTPPublicationRequestFactory(stub)
self.__env = {
'SERVER_URL': 'http://127.0.0.1',
'HTTP_HOST': '127.0.0.1',
@@ -86,7 +90,7 @@
interface.directlyProvides(
browserrequestfactory, interfaces.IBrowserRequestFactory)
component.provideUtility(browserrequestfactory)
- httpfactory = HTTPPublicationRequestFactory(None)
+ httpfactory = self.__factory
env = self.__env
env['REQUEST_METHOD'] = 'POST'
env['CONTENT_TYPE'] = 'text/xml'
Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -20,6 +20,7 @@
from cStringIO import StringIO
from persistent import Persistent
+from ZODB.interfaces import IDatabase
from ZODB.DB import DB
from ZODB.DemoStorage import DemoStorage
import transaction
@@ -45,6 +46,8 @@
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.interfaces import IUnauthenticatedPrincipal, IPrincipal
from zope.app.publication.zopepublication import ZopePublication
+from zope.app.publication.interfaces import IResourceFactory
+from zope.app.zodb.app import ZODBApplicationFactory
from zope.app.folder import Folder, rootFolder
from zope.location import Location
from zope.app.security.interfaces import IAuthenticationUtility
@@ -106,6 +109,8 @@
endInteraction()
ztapi.provideAdapter(IHTTPRequest, IUserPreferredCharsets,
HTTPCharsets)
+ ztapi.provideAdapter(IDatabase, IResourceFactory,
+ ZODBApplicationFactory)
self.policy = setSecurityPolicy(
simplepolicies.PermissiveSecurityPolicy
)
Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -24,6 +24,7 @@
from ZODB.POSException import ConflictError
import transaction
+import warnings
from zope.event import notify
from zope.security.interfaces import Unauthorized
from zope.interface import implements, providedBy
@@ -37,12 +38,12 @@
from zope.location import LocationProxy
from zope.app import zapi
-from zope.app.applicationcontrol.applicationcontrol \
- import applicationControllerRoot
from zope.app.error.interfaces import IErrorReportingUtility
from zope.app.exception.interfaces import ISystemErrorView
+from zope.app.zodb import VERSION_COOKIE, ROOT_NAME
from zope.app.publication.interfaces import BeforeTraverseEvent
from zope.app.publication.interfaces import EndRequestEvent
+from zope.app.publication.interfaces import IResourceFactory
from zope.app.publication.publicationtraverse import PublicationTraverse
from zope.app.security.principalregistry import principalRegistry as prin_reg
from zope.app.security.interfaces import IUnauthenticatedPrincipal
@@ -70,12 +71,16 @@
"""Base Zope publication specification."""
implements(IPublication)
- version_cookie = 'Zope-Version'
- root_name = 'Application'
+ # BBB: these shouldn't be here, but see how much stuff breaks if you remove them:)
+ root_name = ROOT_NAME
+ version_cookie = ROOT_NAME
- def __init__(self, db):
- # db is a ZODB.DB.DB object.
- self.db = db
+ def __init__(self, resource_factory):
+ #BBB
+ if not IResourceFactory.providedBy(resource_factory):
+ warnings.warn("This needs to be a more intelligent warning")
+ resource_factory = IResourceFactory(resource_factory)
+ self.resource_factory = resource_factory
def beforeTraversal(self, request):
# Try to authenticate against the default global registry.
@@ -126,32 +131,8 @@
#recordMetaData(object, request)
self._maybePlacefullyAuthenticate(request, ob)
-
- def openedConnection(self, conn):
- # Hook for auto-refresh
- pass
-
def getApplication(self, request):
- # If the first name is '++etc++process', then we should
- # get it rather than look in the database!
- stack = request.getTraversalStack()
-
- if '++etc++process' in stack:
- return applicationControllerRoot
-
- # 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()
-
- self.openedConnection(conn)
- #conn.setDebugInfo(getattr(request, 'environ', None), request.other)
-
- root = conn.root()
- app = root.get(self.root_name, None)
-
+ app = self.resource_factory(request)
if app is None:
raise SystemError("Zope Application Not Found")
Modified: Zope3/branches/jinty-zodbless/src/zope/app/server/ftp.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/server/ftp.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/server/ftp.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -29,14 +29,15 @@
FTP request factories for a given database create FTP requets with
publications on the given database:
- >>> from ZODB.tests.util import DB
- >>> db = DB()
- >>> factory = FTPRequestFactory(db)
+ >>> from zope.app.publication.interfaces import IResourceFactory
+ >>> class Stub:
+ ... zope.interface.implements(IResourceFactory)
+ >>> stub = Stub()
+ >>> factory = FTPRequestFactory(stub)
>>> from cStringIO import StringIO
>>> request = factory(StringIO(''), {'credentials': None, 'path': '/'})
- >>> request.publication.db is db
+ >>> request.publication.resource_factory is stub
True
- >>> db.close()
"""
zope.interface.implements(IPublicationRequestFactory)
Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/server.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/server.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/server.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -32,11 +32,14 @@
def requestAvatar(self, avatarId, mind, *interfaces):
"""
- >>> from ZODB.tests.util import DB
+ >>> from zope.app.publication.interfaces import IResourceFactory
>>> from utils import FTPRequestFactory
+ >>> class Stub:
+ ... implements(IResourceFactory)
+ >>> stub = Stub()
+
>>> creds = credentials.UsernamePassword('bob', '123')
- >>> db = DB()
- >>> request_factory = FTPRequestFactory(db)
+ >>> request_factory = FTPRequestFactory(stub)
>>> realm = FTPRealm(request_factory)
>>> print realm.request_factory is request_factory
True
@@ -71,7 +74,6 @@
Traceback (most recent call last):
...
NotImplementedError: Only IFTPShell interface is supported by this realm.
- >>> db.close()
"""
if ftp.IFTPShell in interfaces:
@@ -90,10 +92,13 @@
"""
The portal performs a simple authentication
- >>> from ZODB.tests.util import DB
+ >>> from zope.app.publication.interfaces import IResourceFactory
>>> from utils import FTPRequestFactory
- >>> db = DB()
- >>> request_factory = FTPRequestFactory(db)
+ >>> class Stub:
+ ... implements(IResourceFactory)
+ >>> stub = Stub()
+
+ >>> request_factory = FTPRequestFactory(stub)
>>> ftpfactory = FTPFactory(request_factory)
>>> print ftpfactory.portal.realm.request_factory is request_factory
True
@@ -106,7 +111,6 @@
>>> result = deferred.result
>>> print type(result)
<type 'tuple'>
- >>> db.close()
The result variable should be the return value of the 'requestAvatar'
method of the FTPRealm method. This method contains its own test.
Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -56,14 +56,15 @@
FTP request factories for a given database create FTP requets with
publications on the given database:
- >>> from ZODB.tests.util import DB
- >>> db = DB()
- >>> factory = FTPRequestFactory(db)
+ >>> from zope.app.publication.interfaces import IResourceFactory
+ >>> class Stub:
+ ... implements(IResourceFactory)
+ >>> stub = Stub()
+ >>> factory = FTPRequestFactory(stub)
>>> from cStringIO import StringIO
>>> request = factory(StringIO(''), {'credentials': None, 'path': '/'})
- >>> request.publication.db is db
+ >>> request.publication.resource_factory is stub
True
- >>> db.close()
"""
implements(IPublicationRequestFactory)
Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/main.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/main.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/main.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -29,6 +29,7 @@
from zope.event import notify
+import zope.component
import zope.app.appsetup
import zope.app.appsetup.interfaces
import zope.app.appsetup.product
@@ -144,17 +145,26 @@
zope.app.appsetup.config(options.site_definition, features=features)
- db = zope.app.appsetup.appsetup.multi_database(options.databases)[0][0]
+ app_factory = zope.component.queryUtility(zope.app.appsetup.interfaces.IApplicationFactory)
+ if app_factory is None:
+ # We don't have an application factory registered, so we try to make
+ # a ZODB one from the options (probably parsing the options should
+ # just register the utility in future)
+ from zope.app.zodb.app import ZODBApplicationFactory
+ db = zope.app.appsetup.appsetup.multi_database(options.databases)[0][0]
+ app_factory = ZODBApplicationFactory(db)
+ else:
+ # Error rather than do unintuitive stuff
+ assert options.databases is None
+ app_factory.prepare()
- notify(zope.app.appsetup.interfaces.DatabaseOpened(db))
-
# Set number of threads
reactor.suggestThreadPoolSize(options.threads)
rootService = ZopeService()
for server in options.servers + options.sslservers + options.sshservers:
- service = server.create(db)
+ service = server.create(app_factory)
service.setServiceParent(rootService)
return rootService
Modified: Zope3/branches/jinty-zodbless/src/zope/app/wsgi/README.txt
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/wsgi/README.txt 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/wsgi/README.txt 2007-04-05 12:46:25 UTC (rev 74019)
@@ -5,19 +5,20 @@
This package contains an interpretation of the WSGI specification (PEP-0333)
for the Zope application server by providing a WSGI application object. The
first step is to initialize the WSGI-compliant Zope application that is called
-from the server. To do that, we first have to create and open a ZODB
-connection:
+from the server. To do that, we first have to create an object implementing
+IResourceFactory:
- >>> from ZODB.MappingStorage import MappingStorage
- >>> from ZODB.DB import DB
+ >>> from zope.app.publication.interfaces import IResourceFactory
+ >>> from zope.interface import implements
+ >>> class StubFactory:
+ ... implements(IResourceFactory)
+ ... def __call__(self, request):
+ ... return object()
- >>> storage = MappingStorage('test.db')
- >>> db = DB(storage, cache_size=4000)
-
We can now initialize the application:
>>> from zope.app import wsgi
- >>> app = wsgi.WSGIPublisherApplication(db)
+ >>> app = wsgi.WSGIPublisherApplication(StubFactory())
The callable ``app`` object accepts two positional arguments, the environment
and the function that initializes the response and returns a function with
Modified: Zope3/branches/jinty-zodbless/src/zope/app/zcmlfiles/configure.zcml
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/zcmlfiles/configure.zcml 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/zcmlfiles/configure.zcml 2007-04-05 12:46:25 UTC (rev 74019)
@@ -39,6 +39,7 @@
<include package="zope.traversing" />
<include package="zope.app.pagetemplate" />
<include package="zope.app.generations" />
+ <include package="zope.app.zodb" />
<include package="zope.app.zapi" />
<!-- Views -->
Added: Zope3/branches/jinty-zodbless/src/zope/app/zodb/__init__.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/zodb/__init__.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/zodb/__init__.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Zope Application Server setup package for ZODB."""
+
+__docformat__ = 'restructuredtext'
+
+ROOT_NAME = 'Application'
+VERSION_COOKIE = 'Zope-Version'
Property changes on: Zope3/branches/jinty-zodbless/src/zope/app/zodb/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/branches/jinty-zodbless/src/zope/app/zodb/app.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/zodb/app.py 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/zodb/app.py 2007-04-05 12:46:25 UTC (rev 74019)
@@ -0,0 +1,47 @@
+import logging
+
+from zope.app.appsetup.interfaces import IApplicationFactory
+from zope.app.appsetup.interfaces import DatabaseOpened
+from zope.event import notify
+from zope.app.zodb import ROOT_NAME, VERSION_COOKIE
+from zope.interface import implements
+from zope.app.applicationcontrol.applicationcontrol \
+ import applicationControllerRoot
+from zope.app.publication.zopepublication import Cleanup
+
+class ZODBApplicationFactory:
+
+ implements(IApplicationFactory)
+
+ def __init__(self, db):
+ self.db = db
+
+ def prepare(self):
+ notify(DatabaseOpened(self.db))
+
+ def openedConnection(self, conn):
+ # Hook for auto-refresh
+ pass
+
+ def __call__(self, request):
+ # If the first name is '++etc++process', then we should
+ # get it rather than look in the database!
+ stack = request.getTraversalStack()
+
+ if '++etc++process' in stack:
+ return applicationControllerRoot
+
+ # Open the database.
+ version = request.get(VERSION_COOKIE, '')
+ conn = self.db.open(version)
+
+ cleanup = Cleanup(conn.close)
+ request.hold(cleanup) # Close the connection on request.close()
+
+ self.openedConnection(conn)
+ #conn.setDebugInfo(getattr(request, 'environ', None), request.other)
+
+ root = conn.root()
+ app = root.get(ROOT_NAME, None)
+
+ return app
Property changes on: Zope3/branches/jinty-zodbless/src/zope/app/zodb/app.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/branches/jinty-zodbless/src/zope/app/zodb/configure.zcml
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/zodb/configure.zcml 2007-04-05 12:44:56 UTC (rev 74018)
+++ Zope3/branches/jinty-zodbless/src/zope/app/zodb/configure.zcml 2007-04-05 12:46:25 UTC (rev 74019)
@@ -0,0 +1,13 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ >
+
+ <!-- for BBB, allows zope.app.publication.zopepublication.Publication
+ to adapt ZODBs in __init__-->
+ <adapter
+ for="ZODB.interfaces.IDatabase"
+ provides="zope.app.publication.interfaces.IResourceFactory"
+ factory=".app.ZODBApplicationFactory"
+ />
+
+</configure>
Property changes on: Zope3/branches/jinty-zodbless/src/zope/app/zodb/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Zope3-Checkins
mailing list