[ZPT] Re: [Zope-dev] Re: [Vote] PEP308 voting began

Lennart Regebro lennart@regebro.nu
Fri, 07 Mar 2003 15:57:09 +0100


OK, how about this:

1. Python is kept as is.
2. To support one-line if-else in attributes in ZPT, the python 
expressions used in ZPT imports an extra method. This method can be 
called whetever people want it toi be called, but for claritys sake lets 
call it 'if_else'

   if_else(expression, true_result, false_result)

thusly:

<img src="placeholder" tal:attributes="src if_else(has_icon, 
'objectpath/icon', 'images/default_icon')">

Ok, then we can do if-then-else in one line for attributes of ZPT, 
without having to define a pythonscript that does it.

The method if_else would look like:

def if_else(c, a, b):
     if c:
         return a
     else:
         return b


I'm not expert in how python expression work, and hence don't know how 
to make python expressions aware about this method, but I'm sure it's 
possible, right?