Re: [Zope] conditional python expresion inside ZPT

2006-12-05 Thread Maciej Wisniowski

> if (my_expresion):
> toreturn = a
> else:
> toreturn = b
>
> return toretun
Try:
tal:define="toreturn python: my_expression and a or b"

but you need to be aware that 'a' has to be logical True
in context of this statement (if a may be 0 or '' then this
may fail).

or
tal:define="toreturn python: test(my_expression,a, b)"

-- 
Maciej Wisniowski
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] conditional python expresion inside ZPT

2006-12-05 Thread Marco Bizzarri

What about putting the code snippet in a python script and then calling it
from ZPT?

Put it in a script like "mycondition", and then






Regards
Marco


On 12/5/06, Daniel de la Cuesta <[EMAIL PROTECTED]> wrote:


 Hello,

How can I insert a conditional python expresion inside a ZPT.

Example:

if (my_expresion):
toreturn = a
else:
toreturn = b

return toretun

Thank you!







___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )






--
Marco Bizzarri
http://iliveinpisa.blogspot.com/
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )