[Zope] Using ZPT with options/radio/checkboxes

Ron Bickers rbickers-expires-1060892558.da002f at logicetc.com
Thu Aug 7 17:22:01 EDT 2003


> -----Original Message-----
> From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
> Paul Winkler

> > So, how would you write the following more elegantly to handle when
> > 'somevar' doesn't exist?
> >
> > "python:test('A' in path('somevar/letters' | python:[]'), 'checked',
> > nothing)"
>
> I'd make sure it exists :-\
> Seriously, when is this a problem? If somevar is at the top level,
> you've either defined it somewhere or it's one of the built-in names.
> If it's not either one, it must be a mistake.  What am I missing?

Ah.  My explanation wasn't correct.  I'll try again...

If I define somevar as follows, which I commonly do:

  define="somevar session/somevar | nothing"

Then yes, somevar will exist, but if it's 'nothing', it won't have a get
method.  That's when it will raise the exception if I use your code to check
it.

Hmmm... Should I define somevar like this instead?

  define="somevar session/somevar | python:{}"

_______________________

Ron Bickers
Logic Etc, Inc.




More information about the Zope mailing list