OK to use conditional expressions in templates?

Anthony Gerrard <[email protected]>
Newsgroups gmane.comp.web.zope.plone.devel
Message-ID <CAHA8JiT8a1qqs1Gabg8YLuvkvFM1UO_C_9AmHiyJMJpVPTd_qg@mail.gmail.com>
Hi,

I just noticed this bad code™ in navigation_recurse

python: len(children) > 0 and show_children and bottomLevel and level <
bottomLevel or True

It always evaluates to True.  Obviously someone was trying to use the
python 2.4 ternary idiom, C and x or y, without realizing it can't be used
with boolean expressions.

I just wanted to check we can generally drop these in favour of using
conditional expressions?

python: len(children) > 0 and show_children and (level < bottomLevel
if bottomLevel else True)

(fine for Python 2.5+)

Do we need to make it clear there's some backwards incompatibility with
Plone 3.x by bumping the major version number of the package (if it hasn't
already).

Anthony

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech

_______________________________________________
Plone-developers mailing list
Plone-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/plone-developers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.