[Zope] Use of lambda expression in DTML - Result!
Nick Drew
hyperspace@btinternet.com
Wed, 31 May 2000 14:20:50 +0100
Thanks for helping me solve this one. In the end I did the following:
1) hacked DocumentTemplate/DT_Util.py to include "filter" in the __builtins__
2) Installed PythonMethods and called pruneTree with parameter 'self' and content
return _.filter(
lambda x: x.getProperty('pruneFromTree',0)==0 ,
self.objectValues(['Folder'])
)
3) The new tag reads
<dtml-tree name="Outline" leaves=dtcTemplate branches="pruneTree">
Chris McDonough wrote:
|If it's something you want badly (and if you haven't already) add it as
|a feature request to the Collector on Zope.org. Once other folks get
|past the knee-jerk reaction, maybe it'll sink in as a good thing. In
|the meantime, you can add it yourself if you like.
Good idea - I'll do that.
|Hopefully, you'll be so kind as to forgive me.
That's easy - as long as you keep writing HowTos of the same quality as "Zope installation and upgrade" and "Zope enlightenment by understanding object orientation"... :-)
|After seeing people post
|DTML code to the list that they need debugged that computes pay rates,
|has the shape of an arrowhead and scrolls past the maximum character
|length of my email client horizontally, I'm a little leery of adding
|anything whatsoever to DTML, as I think the rest of the folks at DC
|are. Reducing the complexity of DTML is a good thing, however
|it can be accomplished.
Agreed. You can do some very powerful things with the lamda expressions, but they very quickly become unwieldy if used inappropriately, so I think people are right to be wary. Having said that, any sort of block structured language has the same pitfalls - e.g. Smalltalk, Self, even Java's anonymous classes could be used to detrimental effect.
I prefer to leave this stuff to style and convention ("good practice") than prescribe them entirely.
Thanks again,
Nick.