[Zope3-dev] directory hierarchy proposal
Jim Fulton
jim@zope.com
Mon, 16 Dec 2002 08:00:56 -0500
holger krekel wrote:
> Jim Fulton wrote:
>
>>Martijn Faassen wrote:
>>
>>>Jim Fulton wrote:
>>>[snip]
>>>
>>>
>>>>OK, I agree with that. Now, ZODB must be a *namespace* package, according
>>>>to my "namespace" vs "module" package distinction.
>>>>
>>>>
>>>Hey Jim; good to see you made it back. I'm back in the Netherlands again
>>>myself now.
>>>
>>I had a nice uneventful and comfortable pair of flights back, despite the date. ;)
>>
>>
>>
>>>What about the convention that namespace package __init__.py say something
>>>like this:
>>>
>>># this is a namespace package, please keep __init__.py empty of code
>>>
>>>This way anybody tempted to add stuff to an __init__.py where they shouldn't
>>>will be made aware immediately that they shouldn't do that.
>>>
>>This is a good idea, It will need to be modified slightly, since it will
>>contain some boilerplate code to knit all directories of the same name on the
>>Python path into a single logical module.
>>
>
> I am bit uneasy about implicitly collecting modules from several places into
> one namespace package.
Why? The point is to separate physical organization, directories, from logical
organization, the package.
> In which places would a namespace package look?
This is described above. I'll give a detailed example.
Now, suppose my Python path was something like:
[''
'/usr/local/python/latest/lib/python2.2',
'/usr/local/python/latest/lib/python2.2/plat-linux2',
'/usr/local/python/latest/lib/python2.2/lib-tk',
'/usr/local/python/latest/lib/python2.2/lib-dynload',
'/usr/local/python/latest/lib/python2.2/site-packages']
Now, I could install a zope package in in
'/usr/local/python/latest/lib/python2.2/site-packages'
that contained, say, zope.pagetemplates.
I could also have a zope package in the current directory that contained
zope.security.
From Python, I'd be able to:
from zope.pagetemplates import PageTemplate
from zope.security.checker import ProxyFactory
because the two physical zope directories would be merged
into a single package.
> How is this configured?
First, note that packages can define their own package-specific
paths. By default, a package path contains only the package directory,
but it can be changed to include additional directories.
Each zope package __init__ file would have a bit of boilerplate code
that would include all zope directories in sys.path:
# Boilerplate code that combines all zope directories in sys.path
import sys, os
__path__ = [os.path.join(p, 'zope') for p in sys.path]
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org