Am Montag, 18. Juni 2007 13:36 schrieb Brian Sutherland:
> On Mon, Jun 18, 2007 at 07:57:10PM +1000, John Maddison wrote:
> > Hi all,
> >
> > I've just started playing around with using z3c.layer to create
> > applications that don't use the ZMI at all.  Everything is pretty
> > simple so far, except for one fairly important step: creating my
> > initial application object in the ZODB.  What methods do people use to
> > create their application root objects (aside from the ZMI)?
> >
> > Off the top of my head, I can think of a few ways:
> > * Special BrowserPage (named, e.g. 'install-app') that creates the
> > application object and puts it in /
> > * Listening for the ZODB open event and creating/inserting the
> > application object from the handler
> This is the most common way I've seen (schooltool, zope3).

How did you do that? I managed it the following way:

-------------- snip ---------------
from import IDatabaseOpenedWithRootEvent
from import getInformationFromEvent

def addFoobar(event):

    db, connection, root, root_folder = getInformationFromEvent(event)

    if 'swarmfinder' not in root_folder:
        root_folder['foobar'] = Foobar()
------------- snip ----------------

What I dislike here is that there that I use the 
function "getInformationFromEvent", which is already called in the function 
where in the event is triggered; Especially it does a "", 
which is maybe not a good idea as the database is already opened.

Is there a cleaner way?

Best Regards,

GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
Zope3-users mailing list

Reply via email to