[Zope] Recursively read and write folders during install

Chris Withers chris at simplistix.co.uk
Mon Mar 21 03:12:09 EST 2005


robert wrote:
>>
> your product can ask zope where it is installed like:
> product_path = globals()['__builtins__']['INSTANCE_HOME'] + '/Products'

As Dieter pointed out, this can easily be shorted to just 
INSTANCE_HOME+'/Products', but that doesn't mean it'll be correct ;-)

Your best bet is DirectoryViews, but if you do ever want ot know the 
file system path of a Product, then put something like the following in 
the Product's __init__.py:

import os.path
my_path = os.path.abspath(os.path.split(__file__)[0])

...and then you can get it from elsewhere like:

from Products.MyProduct import my_path

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope mailing list