Comment 9 for bug 80403

Revision history for this message
Uli Fouquet (uli-gnufix) wrote :

This issue still persists as Joachims complaint on grok-dev shows:

  http://permalink.gmane.org/gmane.comp.web.zope.grok.devel/4252

Even if the 'Enter module name' option vanishes from grokproject (I know it does), we still have the problem, that Grok incorrectly emits warnings (or even errors in current releases) on 'unassociated templates'.

So the problem reappears, when somebody creates a subpackage with a module named like the subpackage and views and templates in it. In fact it seems to me that we got an ambiguity problem here:

When a pkg 'foo' contains view classes (defined in __init__.py) and a module 'foo' and a template dir 'foo_templates', to which entitiy should the templates in foo_templates be associated? To the package or the same named module? Well, the answer for almost every case would be: to the module.

For templates this could be simply clarified in the template registry by not searching for templates of modules, that are packages. I've 'implemented' this (two lines of code plus tests) in the attached patch on the current grok trunk. The ambiguity would vanish at least for templates.

The 'drawback' would be, that one cannot register package-bound templates, which would be defined in __init__.py. This, however, would be bad style IMHO and I wouldn't care too much for this usecase. In fact I never tried to define views in __init__.py.