[Zope] External Method importing modules

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


Well, I did it:

from App.config import getConfiguration
extPath = getConfiguration().instancehome+'/Extensions'
if sys.path.count(extPath) == 0: sys.path.insert(0, extPath)

And it worked for what I wanted.

On 13/02/07, Alan <alanwilter at gmail.com> wrote:
> On 13/02/07, Andreas Jung <lists at zopyx.com> wrote:
> > What's the sense of this code? sys.path is usually *never* empty.
> > You should really look at the Python docs and learn where Python is looking
> > by default for modules. Is is perfectly documented -> python.org ->
> > documentation.
> >
> > In addition you would like to check for the existence of an item in
> > sys.path using
> >
> >  if myPath in sys.path:
>
> 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
>
> --
> 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<<
>


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