[Zope-dev] connecting server code to the ZODB

Paul Winkler pw_lists at slinkp.com
Fri Nov 5 13:32:55 EST 2004

On Fri, Nov 05, 2004 at 03:34:06PM +0100, Florent Guillaume wrote:
> In article <2233. at> you write:
> > Hi,
> > 
> > I'm trying to figure out how to adjust Nikolay Kim's smtpserver code
> > <http://cvs.sourceforge.net/viewcvs.py/collective/smtpserver/> so that
> > objects within the ZODB can affect the way that messages are received
> > (i.e. veto messages based on certain criteria in the first instance).
> > 
> > My problem is that I don't quite know how to get hold of the ZODB objects.
> >  As far as I can tell, Nikolay's
> > smtpserver.SMTPServer.SMTPChannel.process_message method uses
> > ZServer.PubCore.handle to make the connection, but I don't really
> > understand how this all works.

I hadn't seen this before. Neat project.
Looks like he's created a new asyncore server which cooks up
and inserts request SMTPRequest objects in the ZServer request queue.

> > What I really want to be able to do from the server code is something like::
> > 
> >     root = magic_that_gets_me_zodb_root()
> That magic is basically (from memory):
>   import Zope
>   Zope.startup()
>   root = Zope.app()
> But note that starting up a zope is slow, so you don't want to do that
> very often.

Well, in this case zope is already running.

I think you should use the existing publisher machinery.
Given an SMTPRequest instance foo, you should be able to
do foo.traverse(path, response) and get back an object.
This monster method is defined in ZPublisher/BaseRequest.py


Paul Winkler

More information about the Zope-Dev mailing list