Dear Andreas and Jonathan, first a mistake: I want to access 'Extensions' folder as you mentioned Jonathan, not 'import'. Andreas, I've done that, I can see several path there like .../instance/Products/Sprout/src, .../lib/python/Zope2/Startup etc., but none for .../instance/Extensions. I was hoping that I could get the path where 'Extensions' is because I work with several zope installations in several platforms and I would like to make my module independent of a variable inside its code that should be manually adjusted for every situation. And yes, I am aware about adding the path only once (that's why there's a 'if') and then I avoid recursive insertions. Cheers, Alan On 13/02/07, Jonathan <dev101@magma.ca> wrote:
----- Original Message ----- From: "Alan" <alanwilter@gmail.com> To: "Andreas Jung" <lists@zopyx.com> Cc: <zope@zope.org> Sent: Tuesday, February 13, 2007 8:10 AM Subject: Re: [Zope] External Method importing modules
Thanks Andreas, I am trying with:
if sys.path.count(myPath) == 0: sys.path.insert(0, myPath)
where myPath should be '[Zope installation folder]/instance/import'. So my question now is: is there a variable inside Zope which can returns the 'import' path?
You can easily check what's in your sys.path by having your external method return it.
Typically, the Extensions directory (where your external methods live) are not in the default path and need to be added to sys.path.(warning: be careful on how you do this or everytime your external method gets called it will add to the sys.path and will eventually cause you grief!).
Jonathan
-- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK.