[Grok-dev] five.grok and page templates

Martin Aspeli optilude at gmx.net
Sun Aug 3 19:58:23 EDT 2008


With a lot of help from Philipp, I made five.grok use 
Products.Five.browser.pagetemplatefile.ViewPageTemplateFile today. This 
is necessary to make it work with Plone, and I presume other code that 
makes "Zope 2" assumptions as well, e.g. the user of 'here' or reliance 
on Five's provider: expression support.

We made this work by overriding the ITemplateFileFactory for the '.pt' 
extension from grokcore.view and implementing a ZopeTwoPageTemplate that 
extends PageTemplate and uses a ViewPageTemplateFile in 
setFromFilename(). We also overrode render() to do some aq wrapping and 
call the template in a different way.

Unfortunately, I haven't been able to make setFromString() work. I think 
this will require a view-aware version of 
Products.PageTemplates.ZopePageTemplate.ZopePageTemplate ala 
ViewPageTemplateFile from Five.browser. Currently, it raises 
NotImplemented. This isn't so much a problem for the filesystem .pt 
scanner, but it means that inline Zope 2 style templates won't work.

Also, five.grok's __init__.py does from grokcore.view import *. Thus, 
five.grok.PageTemplate is the Zope 3 one from grokcore.view, not the 
ZopeTwoPageTemplate from five.grok.components. I think this could easily 
get confusing. In fact, many of the ftests in five.grok use the former, 
which means that they're not really testing a Zope 2 world (even if it 
is legitimate to use the Zope 3 template engine in Zope 3 these days).

Should we make five.grok.PageTemplate be a Zope 2 style page template? 
Should we bother to hack up a view-aware ZopePageTemplate for use with 
inline templates?


Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

More information about the Grok-dev mailing list