[Zope3-Users] Namespace/Viewlets

Marius Gedminas mgedmin at b4net.lt
Sat May 27 12:36:47 EDT 2006


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
-- 
9. Okay, then, what do you think about "syntactic noise" in config files?

!@#@!#(#%^!%$@#';,!@# 
	-- http://open.nit.ca/wiki/index.php?page=RetchMail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20060527/7c18d77a/attachment.bin


More information about the Zope3-users mailing list