[Product-Developers] Grok cannot find my template

Gil Forcada gil at usecm.com
Fri Jul 29 10:10:48 UTC 2011


2011/7/29 Mike Metcalfe <mike at metcalfe.co.za>

> Hi,
>
> I've created a product with a dexterity content type and a View. When
> starting the instance it bombs out with:
> View <class 'myproduct.myclass.View'> has no associated template or
> 'render' method.
>
> Higher up in the trace I see:
> UserWarning: File 'view.pt' has an unrecognized extension in directory
> '/path/to/pyproduct/myclass_templates'
>
> I looked in grokcore.view.templatereg.py but I can't work out why it's not
> recognising 'pt' - I must have a error somewhere else.  Can someone point me
> in the right direction?
>
> Regards
> Mike
>

Hi,

If you have created the product with zopeskel.dexterity[1] you should have a
myclass_templates folder where to put your templates. The template should
match the view's name so:

class TwoColumnsView(grok.View):
    grok.context(IMyClass)
    grok.require('zope2.View')

Would have a template called twocolumnsview.pt on myclass_templates/ folder.

If you want to place them somewhere else just do:

grok.templatedir('my_other_templates')

class TwoColumnsView(grok.View):
    grok.context(IMyClass)
    grok.require('zope2.View')
    grok.template("my_shiny_template")

So that view will look up a template on my_other_templates/
my_shiny_template.pt

Hope that helps.

Cheers,

[1] http://pypi.python.org/pypi/zopeskel.dexterity


>
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-product-developers
>
>


-- 

*Gil Forcada**
*C/Llacuna, 166 2n.2a (Edifici Llacuna)
telf: 93.188.88.12 - 619.65.34.92
fax: 93.320.93.97
(08018) BARCELONA
gil at usecm.com
www.usecm.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20110729/9120ee7d/attachment.html>


More information about the Product-Developers mailing list