[Zope3-dev] PEP 333 and Zope

Phillip J. Eby pje at telecommunity.com
Thu Nov 11 14:30:22 EST 2004


At 11:23 AM 11/11/04 +0100, Eckart Hertzler wrote:
>On Wednesday 10 November 2004 16:23, Phillip J. Eby is believed to have said:
> > At 12:14 PM 11/10/04 +0100, Eckart Hertzler wrote:
> >
> > >Ok, just now I checked in the application side.
> > >I tried to incorporate Philips suggestions (hopefully correctyl) and
> > >tried to streamline it a bit.
> >
> > There's a bug in 'getHeaders()', it should use "line.split(':',1)", or 
> else
> > it will break when a header value includes a colon.
> >
>I fixed it.
>
> > However, the startup is still incorrect, because it relies on
> > 'zope.app.server.main.run()', which is not going to be appropriate for use
> > inside say, Apache or Twisted.
> >
> > There needs to be a way to have an object that automatically handles any
> > zope-specific startup, either through its module initialization, or by
> > having it check when it's called.
> >
> > It seems to me that basically, one needs a module or script like:
> >
> >       from zope.app.wsgi import PublisherApp
> >
> >       # ...code to get a database from somewhere
> >
> >       my_app = PublisherApp(database)
> >
> > Then, this module could be used with any server.  The global
> > 'publisherApp', 'bootStrapSubscriber' and 'configure.zcml' should really
> > all go away.
>
>I think this is what zope.app.server.main does, except that you don't get 
>a reference to
>the database from the setup method.
>So, if setup would return the open database you could say
>
>     from zope.app.server.main import setup, load_options
>     from zope.app.wsgi import PublisherApp
>
>     args = ["-C/path/to/zope.conf"]
>     db = setup(load_options(args))
>
>     my_app = PublisherApp(db)
>
>     # do whatever
>
>And if you want to start the ftp server or any other configured server you 
>could always call run()
>
>That way I could indeed throw away the zcml, bootStrapSubscriber and the 
>global publisherApp.
>
>Would that be a correct startup ?

Sounds like it, except that starting other servers is *not* an option for a 
portable WSGI application.  Non-portable stuff should be placed in a 
separate module from the application.

The reason is that for running Zope under say, mod_python, there will just 
be some configuration like:

PythonHandler wsgiref.handlers::modpy_handler
PythonConfig  application some_module::my_app

That will import 'my_app' from the target module.  The WSGI application 
module is *not* a server startup script, and shouldn't be confused with one.



More information about the Zope3-dev mailing list