[Zope] calling another products methods

Terry Hancock hancock at anansispaceworks.com
Tue Dec 2 15:20:19 EST 2003


On Tuesday 02 December 2003 12:59 pm, Dylan Reinhardt wrote:
> On Tue, 2003-12-02 at 10:32, Matthew Thorley wrote:
> > As the subject indicates I am working with a product(P1) and I would like to 
> > call the methods of a different product(P2) from with in the first. When I 
> > try from P@ import method I get an error. How do I get P2 to into the 
> > namespace of P1 or at least into the global namespace. 
> 
> Untested, obviously... but probably close enough to help:
> 
> -----
> from Products.P1.p1module import p1class
> 
> def my_wrapper(self, request):
>     return p1class.p1method(self, request)
> -----

I can attest that this works.  I use it a *lot*, as I have a
product with explicit dependencies on some other products.

I also find that I need to import *my* product modules this
way when I use nested directory/package structure in my
product.  I have not found any equivalent to "../" in the way
Python imports modules, so I can't just "go up a directory".

Is there one, BTW?

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com



More information about the Zope mailing list