[Zope3-dev] wading through zcml...
Martin Aspeli
optilude at gmx.net
Thu Nov 16 06:38:17 EST 2006
Chris Withers wrote:
>
> What's the difference between zope:view, browser:view, browser:page and
> browser:viewlet?
>
I would strongly encourage you to buy Philipp's book when the second edition
comes out, and read some of the available existing documents (e.g.
worldcookery.com, the Zope 3 wiki thingie).
<zope:view /> is deprecated, I believe, an old spelling for <adapter />
before <adapter /> could do multi-adapters.
<browser:view /> is about registering a new view, typically one that doesn't
render a page (so think of it analogous to where you may use a Script
(Python) in Zope 2)
<browser:page /> is about a view typically with an associated template that
renders something for the user
<browser:viewlet /> is about building viewlets, which are small chunks of
HTML that are aggregated into a <browser:viewletManager />. The DocTest in
zope.viewlet explains it all.
> I'm trying to register an adapter in such a way that I can do the
> following in a page template:
>
> <p tal:content="structure someobj/@@render"/>
>
You would use a browser:view with a class deriving from BrowserView
(Products.Five.browser.BrowserView) and did its magic in the __call__ method
i believe. A more common pattern would be to have a method on the view
"render" that you call:
tal:define="renderView someobj/@@render"
tal:content="structure renderView/renderTheData"
> Also, why, when zope:view is described as a synonym for zope:adapter,
> does zope:view support an allowed_attributes attribute, while
> zope:adapter does not?
>
It has to do with the fact that in the olden days, there were no
multi-adapters, and views were special. Then they realised that a view was
in a fact a multi-adapter on context, request, and that this was a more
generally useful pattern.
Martin
--
View this message in context: http://www.nabble.com/wading-through-zcml...-tf2641986.html#a7376076
Sent from the Zope3 - dev mailing list archive at Nabble.com.
More information about the Zope3-dev
mailing list