[Zope] Accessing imported module function

Dylan Reinhardt zope@dylanreinhardt.com
Wed, 22 Jan 2003 08:55:43 -0800


At 07:38 AM 1/22/2003, Stacy Roberts wrote:

>             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.


I'm having difficulty parsing your exact requirements, but here's three 
suggestions that might help.

1. You show your class inheriting from Folder.  Do you also inherit from 
OFS.ObjectManager.ObjectManager?  Odds are, you'll want to.
2. If these three items can all contain each other, it may make things a 
lot easier to define their constructor methods in a base class.
3. To create a 'local' reference to an imported function, do something like:

-----------------
import foo

my_foo = foo.method_name
-----------------

 From then on, any time you call my_foo() in that scope, you're actually 
making a call to foo.method_name()

Hope one (or all) of those helps get you where you're going.

Dylan