[Zope3-dev] Package organization quandry

Barry A. Warsaw barry@zope.com
Fri, 17 May 2002 12:49:34 -0400


>>>>> "SH" == Shane Hathaway <shane@zope.com> writes:

    SH> from Zope.PageTemplate.PageTemplateFile import
    SH> PageTemplateFile from Zope.Security.TALES import
    SH> restricted_TALES_engine

    SH> def ZPTFile(filename, prefix=None): return
    SH> PageTemplateFile(filename, prefix, restricted_TALES_engine)

    SH> So code that depends on Zope.App would get to use the
    SH> ZPTFile() function, while code that doesn't depend on Zope.App
    SH> has to import both PageTemplateFile and the restricted TALES
    SH> engine.

+1

But, referring back to the spaghetti thread (!), if the PageTemplate
package is to be usable outside of Zope, I really want to see that
spelled:

    from PageTemplate.PageTemplateFile import PageTemplateFile

IOW, code that uses PageTemplate should not have to prepend it with a
Zope package prefix.  You accomplish this by developing the
PageTemplate package as a distutils package outside of any Zope
context.  Then Zope's build procedure uses "setup.py install" with
some magic options <wink> to install that in a directory that Zope
guarantees is on sys.path before site-packages, e.g. lib/python in
Zopespeak.

Note that this approach means that "Zope" (whatever that ends up
meaning, probably the sumo tarball distribution) has its own blessed
copies of independent packages, never installs them in site-packages,
and actually never cares if someone else on the machine /has/
installed them independently in site-packages because Zope's never
gonna look there.

The costs are related to duplication of bits; i.e. a particular
machine may have PageTemplate package installed multiple times, say
once in site-packages for use in the user's own toy scripts, once for
Zope in lib/python, and once in Mailman's $prefix/pythonlib <wink>.
Who cares?  Bandwidth and disk space are cheap.

There's some minimal overhead in getting Zope's build procedure to do
the special package installs, and some one time costs for editing
"Zope." out of import statements and (perhaps) for fiddling with the
cvs repository.  All tractable.

-Barry