[Grok-dev] Re: issueing a warning, not an error when template files are not associated

Philipp von Weitershausen philipp at weitershausen.de
Wed Nov 14 05:39:08 EST 2007


Jan-Wijbrand Kolman wrote:
> The following behaviour is bothering me for, like, always, in Grok. I'd 
> like to have your opinion on it:
> 
> Whenever Grok finds a template file that it cannot associate with a view 
> component Grok will raise a GrokError and thus your application won't 
> start.
> 
> Somehow this happens to me a lot; I guess I frequently copy or move or 
> create templates while developing, without (yet) having a view class for 
> it. Then I find Zope not starting and thus I need to somehow disable the 
> template, by renaming it for example (it used to be even harder: you had 
> to move it out of the dir, or prefix the filename with a dot, because 
> Grok would choke on unrecognized names).
> 
> Question: what about just issueing a UserWarning for any template that 
> could not be associated, instead just for the files with an unrecognized 
> filename?

+1

I frequently trip over this as well, especially since I use paster serve 
--reload (which automatically reloads the server when it detects changes 
to the code). Often, when moving things around, it won't come up again 
because of that error.

> As a consequence of the current behaviour:
> 
> By using the module-level grok.templatedir() directive, you can instruct 
> Grok to look into a specific directory for its template. I get the 
> impression however, that you cannot have view components in two seperate 
> modules looking for templates in the same grok.templatedir() - because 
> after grokking the first module, Grok will conclude there're 
> unassociated templates left.
> 
> So, another question: is it possible to raise the GrokError (or the 
> afformentiond UserWarning) about unassociated templates after the 
> grokkking process for a package is completed?

Perhaps. We'd have to introduce a new type of grokker, though. And we'll 
have to introduce a template registry registry (sic!) so that two 
modules can share the same template registry.


More information about the Grok-dev mailing list