[Zope-dev] product import question

Max M maxm@mxm.dk
Tue, 11 Mar 2003 11:51:38 +0100


Eric Roby wrote:

>I attempted to restrict the meta_types in the class that is represented by
>dbFolder to just prodA.  In order to gain access to the prodA add form, I
>had to import the prodA module into the prodB module and make the assignment
>in the class that is represented by dbFolder.  At this point the single
>factory method was exposed in the dbFolder as expected.  Unfortuantely, the
>constructor for prodA (action of the prodA add form) could not be found.
>With numerous tweakings and source searching I settled on duplicating the
>constructor function for prodA in the class that is represented by dbFolder.
>Now it works.
>

You need to import the constructor methods and the assing them to local 
constructor methods.

I use something similar in my "simpleProduct" where I have a base module 
called "mxmSimpleItem" which has 2 constructors:

mxmSimpleItem.py
========================
manage_addForm = HTMLFile('manage_addForm', globals())

def manage_addAction(self, id=None, REQUEST=None):
  "some code"
========================

I then have another module "mxmObjectManager" which is similar to the 
first. So I also need the constructor in the module. Had they only been 
in the class, it would not have been a problem. But I just import them 
and assign them like:

mxmObjectManager.py
========================
import mxmSimpleItem
manage_addForm = mxmSimpleItem.manage_addForm
manage_addAction = mxmSimpleItem.manage_addAction
========================

Which is the right way to do it.

regards Max M