[Zope] External Method importing modules

Alan alanwilter at gmail.com
Tue Feb 13 10:48:41 EST 2007


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 at magma.ca> wrote:
>
> ----- Original Message -----
> From: "Alan" <alanwilter at gmail.com>
> To: "Andreas Jung" <lists at zopyx.com>
> Cc: <zope at 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.
>>http://www.bio.cam.ac.uk/~awd28<<


More information about the Zope mailing list