[Zope-dev] Re: simpler TALES. (was Re: TALES idea: tuple unpacking)

Evan Simpson evan@4-am.com
Wed, 30 Jul 2003 12:19:35 -0500


Paul Winkler wrote:
> you don't :)
> it's a convenience (less stuff to type if you access the object a lot)
> and/or an optimization (getSomeObject might be expensive).

I believe that his example referred to the case where the intermediate 
object must be called before path traversal can continue.  Since the 
result of a path expression is called, if possible, the two-step define 
gets the job done.  With prefixes, the simpler 
"here/getSomeObject/call:/someAttribute" gets the job done.

>>        * Why does tal:content="request/form/items" don't get me the
>>        "items" object that I'm expecting
> 
> you lost me there.

"request/form" is a mapping, and traversal tries attribute access first, 
so you get "request.form.items()" rather than "request.form['items']".

> Hm. Doesn't really matter - ObjectManager makes them equivalent
> anyway (except that some keys cannot be spelled as attributes, 
> e.g.  foo['bar.html']).

Not quite.  Attribute access invokes acquisition, while item access 
never does, so getattr(foo, 'bar.html') may succeed where 
foo['bar.html'] fails.

Cheers,

Evan @ 4-am