[Zope3-Users] Namespace/Viewlets

David Johnson djohnson at jsatech.com
Sat May 27 12:56:16 EDT 2006


Ah ha! You've discovered it. I was not inheriting from BrowserView.  

Thanks!

On Sat, 2006-05-27 at 19:36 +0300, Marius Gedminas wrote:
> On Fri, May 26, 2006 at 10:54:46PM -0500, David Johnson wrote:
> > I have a viewlet named "cart", which can be displayed with the following
> > TAL code and rendered via <browser:page> :
> > 
> > <div tal:content="structure provider:cart/>
> > 
> > It works great!
> > 
> > However, the exact same page when rendered via ViewPageTemplateFile
> > generates an exception:
> > 
> > ContentProviderLookupError: u'cart'
> > 
> > What gives?
> 
> How do you use the ViewPageTemplateFile?
> 
> As far as I can tell, <browser:page template="foo.pt" class=".FooView">
> is indistinguishable from
> 
>     class FooView(BrowserView):
>         index = ViewPageTemplateFile("foo.pt")
> 
>         def __call__(self):
>             return self.index()
> 
> so if viewlets work in one case, they should work in the other as well.
> 
> If your ViewPageTemplateFile is not a class attribute, the descriptor
> magic does not happen and it does not know what view it belongs to.
> In that case this should be the correct usage:
> 
>     class FooView(BrowserView):
> 
>         def __call__(self):
>             template = ViewPageTemplateFile("foo.pt")
>             return template(self)
> 
> Big Fat Disclaimer: I'm writing from memory and could be completely
> wrong.
> 
> Marius Gedminas
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users



More information about the Zope3-users mailing list