Package Organization (was Re: [Zope3-dev] Voting on Schema design)
Barry A. Warsaw
barry@zope.com
Mon, 15 Jul 2002 14:59:02 -0400
>>>>> "JF" == Jim Fulton <jim@zope.com> writes:
JF> Why? The seach order should be governed by sys.path, just as
JF> for any module search.
JF> Would you want a different search order that sys.path?
Nope, you're right, sys.path is /exactly/ the mechanism to control
this. You won't be able to order from a Chinese menu ("I'd like
PackageA from patha but PackageB from pathb"), but moving them out of
the Zope placeholder package wouldn't help you.
So this should go in Zope/__init__.py:
-------------------- snip snip --------------------
import os
import sys
for dir in sys.path:
fullpath = os.path.join(dir, 'Zope')
initfile = os.path.join(fullpath, '__init__.py')
if os.path.exists(initfile) and not fullpath in __path__:
# The other package be searched later
__path__.append(fullpath)
-------------------- snip snip --------------------
Now we just have to figure out how to make this work with the
distutils way of things. ;)
-Barry