[Zope] is it possible to add numerical comparison test to dtml-in statement ? statement ?

Stephen Pitts smpitts@midsouth.rr.com
Sun, 9 Jan 2000 12:09:10 -0600


On Sun, Jan 09, 2000 at 02:31:49AM +0800, chas wrote:
> When looping over ZClass instances in a dtml-in statement,
> I have constantly wanted to add a numerical test condition
> (eg. "where X > 12" where X is a property of the instance) 
Yep, since <dtml in "foo"> evaluates foo as a Python expression, the
following should be possible:
<dtml in "_.filter(objectValues(['MyClass'], lamba x: return x > 12)">

filter(alist, func) returns a list of all items in alist for which func
returns true. The lamba construct can be used to define a function on
the fly, similar to LISP and other functional programming languages. 
lamba x: return x > 12
is the same as:
def afunc(x): 
	return x > 12
-- 
Stephen Pitts
smpitts@midsouth.rr.com
webmaster - http://www.mschess.org