[Zope-dev] connecting server code to the ZODB
tim at sitefusion.co.uk
Wed Nov 10 19:41:21 EST 2004
Paul Winkler said:
>> Ok, so I could simply drop the Zope.startup() line and things would be
>> fine (and quick), right?
> I haven't tried it, but I think doing Zope.app() will try to
> acquire a lock on the database and it is already locked by
> the running Zope (or ZEO). So I don't think you can do that.
Ok, I think I follow that.
>> > 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
>> What does using foo.traverse() buy me over simply accessing the ZODB
>> objects 'by hand', as in root = Zope.app()?
> Well, for one thing it might actually work ;-)
Good point :-). The only thing is that I'm not sure that I actually am
able to call foo.traverse() before it gets passed into handle() (see
below) because I don't think that it will be populated with 'PARENTS'
before it's been 'sent to zope'.
> Note, I'm not sure what your code looks like - if you already
> have a reference to any persistent object (as long as it's
> Traversable which basically anything of interest to you would be),
> you can get the root by doing root = someObject.getPhysicalRoot().
Nope, I don't have a reference to a persistent object. I'm looking at the
code in smtpserver.SMTPServer and trying to figure out what I need to
adjust. As far as I can tell, the only point in that code at which a
'link' to zope/zodb objects is made is in the following call in
handle(self.server.module, request, response)
My immediate problem is that I don't understand how the result of this
call gets dealt with. It just seems to get discarded in the smtpserver
code. If this is the way to interact with the publisher, how do I get
hold of the return value?
I'm assuming that by adjusting the REQUEST['PATH_INFO'] value before
calling handle(), I can affect which ZODB object/method gets called, but I
want to know the result of this call.
More information about the Zope-Dev