[Grok-dev] Using five.grok to add new viewlets
Vincent Fretin
vincent.fretin at gmail.com
Sun Jan 18 05:43:47 EST 2009
Hi,
After changing my code according to Sylvain suggestions to:
grok.templatedir('templates')
class AdViewlet(grok.Viewlet):
grok.baseclass()
grok.template('adviewlet')
def getBanner(self): pass
class AdHomeViewletManager(grok.ViewletManager):
grok.name('admanager.home')
class AdHomeViewlet(AdViewlet):
grok.viewletmanager(AdHomeViewletManager)
I had the following error:
TraversalError: (<Products.Five.metaclass.Plone object at 0xe2e3f90>,
'getBanner')
It's because I used view/getBanner instead of viewlet/getBanner in my template.
Why with my old code, I can do view/getBanner, it means view variable
is the viewlet here. It's normal or a bug?
My old code:
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
class AdViewlet(grok.Viewlet):
grok.baseclass()
template = ZopeTwoPageTemplateFile('templates/adviewlet.pt')
def render(self):
return self.template()
Sylvain, after reading the ftests, I understood how grok.PageTemplate
is supposed to work. Nice.
--
Vincent Fretin
More information about the Grok-dev
mailing list