The difference between getattr and restrictedTraverse

Tom Lazar lists at tomster.org
Sun Jun 10 15:13:01 UTC 2007


On Jun 10, 2007, at 1:51 PM, Tim Hicks wrote:

> This compares to what I envisage the view approach looking like::
>
>   <div tal:repeat="brain weblog/getLazyEntries">
>     <a tal:define="weblogentryview brain/@@weblogentryview"
>        tal:attributes="href weblogentryview/getArchiveURL"
>        tal:content="brain/Title">title</a>
>   </div>

except that i wouldn't do the 'brains dance' inside the template but  
in the view class.

i've adopted the practice of only passing out dictionaries or adapted  
objects into my templates.

the `getLazyEntries` method is an implementation detail that should  
be abstracted from the template.

without looking at the current interfaces i would postulate having a  
`getEntries` method for `IWeblogView` that simply returns instances  
that provide `IWeblogEntry` -- that's all the template needs to know.

> Maybe the latter is better simply because it is less "magic" and I'm
> over-estimating the down-side of not using the standard API.

bingo! (IMHO)...

;-)

tom




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20070610/b5b91ab0/attachment-0002.html>


More information about the Product-Developers mailing list