[Zope3-dev] Re: Zope 3 without ZODB

Philipp von Weitershausen philipp at weitershausen.de
Sat Jan 20 07:37:50 EST 2007


Chris Withers wrote:
> Hey All,
> 
> I'm still continuing poking around (when I have the chance) to see how 
> I'd get Zope running without ZODB.
> 
> Does the following line:
> 
> db = zope.app.appsetup.appsetup.multi_database(options.databases)[0][0]
> 
> ...from:
> 
> http://svn.zope.org/Zope3/trunk/src/zope/app/server/main.py?rev=71011&view=markup 

Note that there are two main.py files, one for zope.server in 
zope.app.server and one for twisted.web2 in zope.app.twisted.

> ...mean that Zope 3 is currently hard-coded to need a ZODB?

Yes.

> If so, how should we go about making this optional?

We would check if options.databases if empty. If that's so, we could set 
'db=None'.

The 'db' object (the database) gets passed a long to the ServerTypes 
which pass it along to the WSGIPublisherApplication which then passes it 
along to the request/publication factory. This way, when a new request 
is created and a publication object with it, the publication has the 
database to start traversal off of. As far as I can see it, the 
publication is the only component in that whole chain that expects the 
'db' object NOT to be None. So, you'd have to write your own publication 
that wouldn't use the 'db' object for a traversal root but your own 
custom object, e.g.:

class MyPublicationMixin(object):
     """Mix this in with BrowserPublication, HTTPPublication, etc."""

     def getApplication(self, request):
         stack = request.getTraversalStack()
         if '++etc++process' in stack:
             return applicationControllerRoot

         myroot = RootObject()
         return ProxyFactory(myroot)

> (I am willing to put the work in to make this happen if people give me 
> some hints...)

Changing zope.app.server.main and .twisted.main to accept an empty 
database section in zope.conf and thus set 'db=None' would probably be 
all that's needed, plus your custom publication that ignores the 'db' 
argument. Would be cool if you could document this, though :)


-- 
http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!


More information about the Zope3-dev mailing list