grok doesn't like explicit grok.template() if it matches implicitly found template

Bug #242698 reported by Ivo van der Wijk
2
Affects Status Importance Assigned to Milestone
grok
Fix Committed
Medium
Jan Wijbrand Kolman
1.0
Won't Fix
Medium
Jan Wijbrand Kolman
1.1
Fix Committed
Medium
Martijn Faassen

Bug Description

Consider

class AppCSS(grok.Viewlet):
    grok.template("appcss.pt")
    grok.viewletmanager(Head)
    grok.context(ISomeTheme)

grok will complain with the error:

  File "/Users/ivo/.buildout/eggs/tmpaT3RbW/grok-0.12.1-py2.4.egg/grok/templatereg.py", line 101, in checkTemplates
zope.configuration.config.ConfigurationExecutionError: martian.error.GrokError: Multiple possible templates for viewlet <class 'microbio2.viewlets.AppCSS'>. It uses grok.template('appcss.pt'), but there is also a template called 'appcss'.

Essentially, grok complains because I'm too explicit: grok.template("appcss.pt") results in the same template that grok finds implicitly. In my opinion, this might cause a warning but it should not be considered an error. Also, there is no template called 'appcss', it's still appcss.pt

removing the grok.template line makes the error disappear.

Revision history for this message
Martijn Faassen (faassen) wrote : Re: [Bug 242698] [NEW] grok doesn't like explicit grok.template() if it matches implicitly found template

grok.template expects a template name without extension, I think. What
happens if you use 'appcss' without the '.pt'?

Revision history for this message
Ivo van der Wijk (ivo-m3r) wrote :

that fixes it :)

But then shouldn't grok complain it can't find appcss.pt?

Revision history for this message
Martijn Faassen (faassen) wrote : Re: [Bug 242698] Re: grok doesn't like explicit grok.template() if it matches implicitly found template

On Tue, Jun 24, 2008 at 6:05 PM, Ivo van der Wijk <email address hidden> wrote:
> But then shouldn't grok complain it can't find appcss.pt?

In this case that would indeed look nicer. Patches with tests are
welcome, I'm not sure how hard it would be to make it behave more
nicely. We could also decide to detect the use of an extension in
grok.template and fail if that happens.

Revision history for this message
Reed O'Brien (reedobrien) wrote :

On Jun 24, 2008, at 1:30 PM, Martijn Faassen wrote:

> On Tue, Jun 24, 2008 at 6:05 PM, Ivo van der Wijk <email address hidden> wrote:
>> But then shouldn't grok complain it can't find appcss.pt?
>
> In this case that would indeed look nicer. Patches with tests are
> welcome, I'm not sure how hard it would be to make it behave more
> nicely. We could also decide to detect the use of an extension in
> grok.template and fail if that happens.
>
> --
> grok doesn't like explicit grok.template() if it matches implicitly
> found template
> https://bugs.launchpad.net/bugs/242698
> You received this bug notification because you are subscribed to grok.

I assume you mean explicitly detect a '.pt' extension and not '.html'
'.xml' et al.

What about snipping off the .pt and using the rest as the name.

At first I didn't like the name without the extension, but then I
changed my mind.

I would specifically be thinking I want this to go to 'foo.html'. In
which case I don't think of the '.pt' bit when I am typing.

Revision history for this message
Martijn Faassen (faassen) wrote :

I think what we could perhaps do is explicitly detect the presence of
an extension at all in grok.template, and complain if so. It's of
course *possible* there's something lying around called foo.pt.pt, but
I think we shouldn't worry too much about supporting that case.

todd (todd-infrae)
Changed in grok:
assignee: nobody → brandon-rhodes
milestone: none → 1.0
Changed in grok:
assignee: brandon-rhodes → janwijbrand
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Reinout van Rees (reinout) wrote :

See https://bugs.launchpad.net/grok/1.0/+bug/225855 : "grok.template doesn't complain if the given template does not exist". With the render() method gone from regular View classes, we can be more explicit about missing templates.

Revision history for this message
Jan Wijbrand Kolman (janwijbrand) wrote :

the referenced issue 225855 has been fixed and fixes most of the problems in this issue, except for the file extension part that will be ignored in the issue.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.