conditional python expresion inside ZPT
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!
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 <div tal:define="x here/mycondition"> <!-- use x here --> </div> Regards Marco On 12/5/06, Daniel de la Cuesta <daniel.cuesta@iavante.es> 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/
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
participants (3)
-
Daniel de la Cuesta -
Maciej Wisniowski -
Marco Bizzarri