[Zope] Using ZPT with options/radio/checkboxes

Ron Bickers rbickers-expires-1060890307.5f0dea at logicetc.com
Thu Aug 7 16:44:30 EDT 2003


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

> > <input type="checkbox" name="toppings:list" value="Pepperoni"
> > tal:attributes="checked python:test('Pepperoni' in
> path('request/toppings |
> > python:[]'), 'checked', nothing)" />
> >
> > Not quite as elegant, but it's not horrible and it behaves as
> expected, yes?
>
> nested python: expressions.... hmm... sorry to say that pushes it
> over the "horrible" mark for me :-\

I remember now why I used the path() function with a nested python
expression instead of the get method...

If you're using a variable other than 'request' (which we know will exist),
you'll get an exception if that variable doesn't exist.  The path() function
handles this gracefully and returns nothing.

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)"

_______________________

Ron Bickers
Logic Etc, Inc.




More information about the Zope mailing list