[Zope3-dev] Importing

Guido van Rossum guido@python.org
Wed, 12 Dec 2001 23:20:28 -0500


> I have a fairly rich CMF based product (CMF chosen for it's 
> component-model-like features more than any need for actual content 
> management features).  As I noticed that the amount of modules was 
> increasing dramatically, I broke the product out into sub-packages:
> 
> myproduct/base
> myproduct/content
> myproduct/interfaces
> myproduct/tools
> myproduct/workflow
> 
> base has some common base clases, so an import in 
> content/contact.py looks like:
> 
> from Products.myproduct.base import FolderyContent
>       ^^^^^^^^
> 
> I interpreted Chris Withers' original question to be about - what 
> happens if that lead "Products" goes away?  It's something we're 
> well used to having around.  How am I supposed to reference 
> associated subpackages if it's not there?  Am I designing my code 
> poorly?  Am I missing out on some undocumented __magic__ 
> variable/attribute?  Or am I just confused about where this 
> discussion has been / is going?

Assuming you have picked a unique name for your product (like
"myproduct" :-), what's wrong with changing all your imports to

    from myproduct.base import FolderyContent

???

--Guido van Rossum (home page: http://www.python.org/~guido/)