[Zope3-dev] Registering a Content Factory object

Stephan Richter stephan.richter@tufts.edu
Fri, 11 Apr 2003 08:47:47 -0400


On Thursday 10 April 2003 04:34, Marius Gedminas wrote:
> On Wed, Apr 09, 2003 at 07:41:29AM -0400, Stephan Richter wrote:
> > On Wednesday 09 April 2003 03:24, Steve Alexander wrote:
> > > Stephan Richter wrote:
> > > > I use the content directive (including the factory subdirective) to
> > > > define a new content object and its factory. However, now I would
> > > > like to define a special Factory that will create the content object.
> > > > How do I so this?
> > >
> > > A factory is a callable object, such as a class or a function or a
> > > class method or a static method.
> >
> > Right, but in the content directive I have to give the class name and it
> > is assumed that this is class name is also the factory, so I have no way
> > to specify a function as factory.
>
> You could use the regular <factory> directive, which is not a subdirective
> of <content>.  See doc/zcml/namespaces.zope.org/zope/factory.stx
> I've found only one place in Zope 3 where that directive is actually
> used -- src/zope/app/services/translation/configure.zcml

Interesting. I wrote that code and I asked the question. :-) But I had looked 
this up already and the combination of <content> and <factory> would not have 
worked. 

However, I solved the problem otherwise. I had to ask the user some questions 
before creating the Wiki anyways, so that I put it in the addform BrowserView 
class. 

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training