[Zope] Why is it so hard to do simple things?

John Adams jadams@inktomi.com
Wed, 8 May 2002 03:59:47 -0700 (PDT)


On Tue, 7 May 2002, Chris McDonough wrote:

> Python does indeed short-circuit this statement and it will work as you
> seem to expect.  Have you tried it?

Yes, it fails with attribute errors, but that was as part of a dtml-if.

> In DTML, here is something that will do what I think you want.

Thanks, I'll try this.

> Since there are only a couple of possible values, it's probably easier
> just to spell it all out in this case.
>
> I'd suggest picking up the "Learning Python" O'Reilly book to learn
> basic idioms like this.  The thing you were missing was that
> dictionary-like objects (of which REQUEST is one) have a get method that
> returns None if nothing of that key exists in the dictionary on a lookup.

Oh! Cool, so if it's accessed with the REQUEST method, i'll get none, and
directly (as an attribute) it'll fail then?

-john

-- 
John Adams         . Sr. Security Engineer . Inktomi Corporation