[Zope-CMF] Problems with initializing my product

hazmat hazmat@objectrealms.net
Wed, 2 Oct 2002 06:19:24 -0700


On Wednesday 02 October 2002 04:50 am, Gitte Wange wrote:
> On Wed, 2002-10-02 at 12:34, hazmat wrote:
> > you could download gideon
> >
> > from http://www.zope.org/Members/k_vertigo
> >
> > it uses a dynamic subproduct initialization system.
>
> Thanx for the tip - I got it up'n'running :-)))
>
> I just discovered one silly thingy - the fti's of the modules in the
> parent object gets overruled by the fti in the sub product.
> Anyone know why this happens ?

its just a consequence of how utils does initialization, and how the types 
tool does scanning for type infos. it royally sux, imo. there really is a 
whole lot you can do about it without hacking on core stuff, afaics. one 
thing you can do which should work is gather up all the ftis that all 
subproducts and the product are going to register in one tuple, and then use 
that tuple for all the content inits. that should work, although in a dynamic 
subproduct loading scheme, its probably going to be a pain. basically 
something like this

#pseudocode
all_ftis = []

product_ftis = ()

def initialize(context):
   
   global all_ftis

   for m in submodule:
       sub_module = load_subproduct_module(m) 
       all_ftis.extend(sub_module.fti)

   for m in submodule:
       m.initialize(context)

   utils.ContentInit( fti=tuple(all_ftis)).initialize(context)

and have m.initialize  import back from the product to get the all_ftis and 
tuplize it.

hth,

-haz

> > On Wednesday 02 October 2002 02:11 am, Gitte Wange wrote:
> > > On Wed, 2002-10-02 at 10:09, Gitte Wange wrote:
> > > > Hi guys (and girls if any besides me *S*)
> > > >
> > > > I have a problem with one of my products.
> > > > The initialize function in my __init__.py module doesn't get called
> > > > :-( I know this because I made some log statements.
> > > >
> > > > So I was just wondering:
> > > > Where does this initialize function get called from ??
> > >
> > > Just smalltalking with myself :-)
> > >
> > > Uhm ... found the place the function gets called at ..
> > > The product I am trying to initialize are not located in the 'Products'
> > > dir - it's a sub-product to one of my Products - thats why it doesn't
> > > get called.
> > >
> > >
> > > The structure's like this:
> > > Product
> > >
> > >
> > >  -- SubProduct
> > >
> > > Hmmm ... will I need to do the same code gymnastics that are done in
> > > OFS.Application.install_product ?
> >
> > _______________________________________________
> > Zope-CMF maillist  -  Zope-CMF@zope.org
> > http://lists.zope.org/mailman/listinfo/zope-cmf
> >
> > See http://collector.zope.org/CMF for bug reports and feature requests