[Zope3-dev] Last chance to mess with the source layout of Zope 3

Jim Fulton jim at zope.com
Fri Feb 13 10:00:11 EST 2004


Martijn Faassen wrote:
> Stephan Richter wrote:
> 
>>Yes, this is how I develop Zope 3 products these days. If the browser code is 
>>minimal and has only 1-2 templates I use browser.py otherwise I am shifting 
>>to a directory browser, but usually leave the views in __init__.py, so that 
>>the imports don't change.
> 
> 
> Putting stuff in __init__.py... Why don't you use modules and 'from .. import'
> the views into __init__.py if you want to do this? Much cleaner.
> 
> 
>>Also, I have recently started to move implementation of interfaces to 
>>__init__.py as well.
> 
> 
> Putting a ton of stuff into __init__.py sounds like bad practice to me.
> It's very easily avoided by placing a few 'from .. import' statements in your
> __init__.py and doing the rest in a module where they belong.

I think you are probably right.  It's a little tough for small packages.
I find myself often wanting to create very small view packages that
have a single python file and some ZPT and ZCML files.

Suppose we have a package foo.  I'm inclined to have:

   foo:

     foo.py
     __init__.py
     configure.zcml
     bar.pt
     spat.pt

and in __init__.py having:

   from foo.foo import *

I've been uncomrfortable with repeating names inside packages, and
I certainly want to avoid clients doing:

   from foo.foo import x

but I'm less confortable with heavy __init__.py modules.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Zope3-dev mailing list