[Zope] Multiple Products directories
Duncan Booth
duncan@rcp.co.uk
Tue, 10 Apr 2001 14:34:42 +0100
> Hi Everyone,
>
> Is it possible to have multiple Product directories? I wish to get a
> shared Products directory between multiple zope instances without
> using the Products dir in the zope tree itself (as this may get
> updated, removed, etc). Each site already has its own INSTANCE_HOME
> for its own, private products, so this one cannot be used.
>
Yes you can simply by appending another directory to
Products.__path__. The question then comes where the best place
to add it would be.
If you are prepared to edit Products/__init__.py add a line:
__path__.append('yourpathhere')
for each directory you want to add to the default Products directory.
Alternatively if you want to avoid editing Products/__init__.py you
can inject the extra paths from outside, e.g. from z2.py:
import Products
Products.__path__.append('extraProductDir')
A good place to do this might be custom_zodb if, for example you
are using ZEO, although I haven't checked to see whether this
would be early enough in the startup, if done too late the extra
products won't be picked up.
Another option is to create a product to make the change for you.
Create a subdirectory in Products called anything you like. e.g.
ExtraProducts. Create a file in this directory __init__.py containing:
import Products
Products.__path__.append('extraProductDir')
Change the path to reflect your desired directory structure, restart
Zope and you should now pick up products from both directories.
In some ways this is cleaner as it isolates the change so you dont
have to worry when upgrading your zope system, but it actually
works by changing a variable while a for loop is iterating through its
contents which tends to worry me.
--
Duncan Booth duncan@rcp.co.uk