[Zope] Accessing imported module function

Stacy Roberts stacyl_roberts@yahoo.com
Wed, 22 Jan 2003 07:38:17 -0800 (PST)


I am in the process of developing a Python product for
Zope. I have created several container (folderish)
objects, and have come across a problem when two
objects can recursively contain each other. 

For example, I will explain 3 of my modules:

    In module CITATION.py,  I have the following
import statement. This should place this module into
my sys.modules dictionary. 

            import CITEINFO

            class CITATION(Folder):
                 <all the class stuff here>
                 add_citeinfo=CITEINFO.add_citeinfo

    In module CITEINFO.py

            import LWORKCIT
   
            class CITEINFO(Folder)
                <all the class stuff here>

            def add_citeinfo(self, ..., ...):
               <function statements here>

    In module LWORKCIT.py

            class LWORKCIT(Folder)

            def add_lworkcit(self, ..., ...):
                <function statements here>

            This is where my problem lies. In the
class statements, I need to gain access to the
CITEINFO.py modules add_citeinfo function. 
            The CITEINFO.py module exists in the
sys.modules and I can retireve it with the following
statement:
    module = sys.modules 'Products.METADATA.CITEINFO']

             However, I do not know how to gain a
reference to the add_citeinfo function. 


Inside my 'def add_lworkcit()' function, I make the
follwoing call:
 
withIt.manage_addProduct['METADATA'].add_citeinfo('citeinfo')
                It appears the add_citeinfo defined in
the CITATION.py module is called (since I am unable to
define a variable add_citeinfo in my LWORKCIT class. 
                My 'citeinfo' object is added to Zope,
but in the wrong namespace. 
                'withIt' is the LWORKCIT namespace I
want the 'citeinfo' object created in. It seems to
ignore this and create a citeinfo object in the
CITATION object. 

If further information, explanation, or code is needed
for someone to provide me with a little help, please
ask and I will elaborate.
Any insight into a solution would be greatly
appreciated. Thank you in advance.


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com