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

Marius Gedminas
9. Okay, then, what do you think about "syntactic noise" in config files?

        -- http://open.nit.ca/wiki/index.php?page=RetchMail

Attachment: signature.asc
Description: Digital signature

Zope3-users mailing list

Reply via email to