[Grok-dev] Module with the same name as package

Philipp von Weitershausen philipp at weitershausen.de
Wed Jan 17 05:50:01 EST 2007

Let's say you have a package called 'herd' and in that package you have 
a module with the same name 'herd/herd.py'. Now you want to associate 
templates with stuff in herd.py.

grok currently interprets a 'herd/herd_templates' directory as one that 
belongs to the 'herd' *package*, not to the 'herd.py' module. It 
therefore throws an error that it can't associate the templates in 
herd_templates with any model (since it's looking in herd/__init__.py 
and not herd/herd.py).

This is a problem as the error message isn't clear enough about what's 
wrong. There are several ways to fix this:

a) We don't support a 'herd.py' module in a 'herd' package. 
'herd/herd_templates' would be the tempaltes directory for the 'herd' 
package. If a 'herd.py' module is found in the 'herd' package, an error 
is raised.

b) We support a 'herd.py' module in the 'herd' package and allow 
templates to be associated with 'herd.py' *ONLY*. 'herd/herd_templates' 
would be the template directory for 'herd/herd.py'. The usage of 
grok.template in 'herd/__init__.py' would raise an error.

c) We support a 'herd.py' module in the 'herd' package and also allow 
templates to be associated with stuff in 'herd/__init__.py'. The 
template directory could be 'herd/templates', or 
'herd/__init___templates', or something weird like that.


http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!

More information about the Grok-dev mailing list