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

Paul Winkler pw_lists@slinkp.com
Wed, 30 Jul 2003 14:02:20 -0400


On Wed, Jul 30, 2003 at 12:19:35PM -0500, Evan Simpson wrote:
> 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.

ah, i see. hm, well if getSomeObject is a Python Script, it's 
called anyway and it can only deal with someAttribute in its 
traverse_subpath anyway.

> >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.

Ugh. I don't know how I've been using zope 2 this long without noticing
that item access doesn't acquire. But i just checked and by golly, 
you're right. I have to say, that's pretty horrible. :-)
Is that documented anywhere? I've never seen it if so.

And getattr(foo, "some.string.that's.not.a.valid.python.varname")
is just aesthetically bad. :-\

yay zope 2... "principle of most surprise" wins again :-(

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's OVERLY PADDLE SADIST!
(random hero from isometric.spaceninja.com)