[Zope3-Users] Autocreated content objects

John Maddison maddisjohn at gmail.com
Tue Sep 26 03:39:48 EDT 2006


On 9/25/06, Stephan Richter <srichter at cosmos.phy.tufts.edu> wrote:
> On Monday 25 September 2006 03:21, John Maddison wrote:
> > Is it possible/wise to "auto-create" content objects in the ZODB? Say I'm
> > creating a blog application and have a container type(BlogContainer) and
> > want an instance called "blog" in the root of the ZODB. Is it possible to
> > programatically specify this, or is my only option to create it through the
> > ZMI? I thought that perhaps an event was generated when the root object was
> > created that I could hook into, but it seems not. Perhaps I'm looking at
> > this the wrong way - would "fixtures" like this be better implemented as
> > utilities with z3c.traverser redirecting to appropriate views?
>
> It is very much a goal of Zope 3 to allow Python-based content adding; in
> fact, I am never adding content via ZMI these days. The closest I get to the
> ZMI is the Sample Data generator that creates a full application for me. By
> the way, much thanks to SchoolTool, Roger and Juergen who have developed this
> concept. We also use the configurator to configure complex content objects.

Hm...a few thoughts on this: firstly,. if you're using this in a
production application, the module name seems a bit misleading :).
Secondly, I'd've expected the context that gets passed t the plugin
would be either the sample object itself or the root object, but it
seems to be none - how can I get the root object? Finally, it seems to
make the problem a bit more indirect, but still there - how could I
automatically create  a SampleManager on startup?  With the new event
(I gather that would work - I guess I'm askign what the "best
practice" would be, if in fact I'm not trying to do something silly to
begin with)?

> So to answer your specific question: There is an event fired when the database
> is opened with the root. See zope.app.appsetup.bootstrap, line 193. Hoever, I
> agree that an created and add event should be created for the root folder in
> the same function. Could you file a bug report, or even better provide a fix
> with test? :-)

Fred already did it :)

Also, thank you  to everyone for your quick and varied answers - zope3
is generally fairly well documented at the code level, and it's great
to know it's easy to find answers to more architecture-y questions,
too.


More information about the Zope3-users mailing list