Hi, A little question about the "dtml-in" tag. What I'd like to do is to build a list according to a property value, like we can do with for "for" Python instruction, something like : <dtml-in "object for object in objectValues() if object.visible"> Is there any way to achieve this, without writing a custom method ?? Thanks, Thierry -- Linux every day, keeps Dr Watson away... http://gpc.sourceforge.net -- http://www.ulthar.net
Thierry Florac wrote:
Hi,
A little question about the "dtml-in" tag.
What I'd like to do is to build a list according to a property value, like we can do with for "for" Python instruction, something like :
<dtml-in "object for object in objectValues() if object.visible">
Is there any way to achieve this, without writing a custom method ??
Use a PythonScript or something like ZopeFind from lib/OFS/FindSupport.py (works the same way as you click Find on a Folder, just call it directly): def ZopeFind(self, obj, obj_ids=None, obj_metatypes=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_permission=None, obj_roles=None, search_sub=0, REQUEST=None, result=None, pre=''): """Zope Find interface""" Example: <dtml-in "ZopeFind(this(), obj_expr='visible')"> <dtml-var getId> </dtml-in> -mj
On Friday, January 24, 2003, at 06:38 AM, Thierry Florac wrote:
A little question about the "dtml-in" tag.
What I'd like to do is to build a list according to a property value, like we can do with for "for" Python instruction, something like :
<dtml-in "object for object in objectValues() if object.visible">
Is there any way to achieve this, without writing a custom method ??
<dtml-in objectValues()> <dtml-if visible> ... </dtml-if> </dtml-in> ___/ / __/ / ____/ Ed Leafe http://leafe.com/ http://opentech.leafe.com
On Fri, 2003-01-24 at 14:23, Ed Leafe wrote:
On Friday, January 24, 2003, at 06:38 AM, Thierry Florac wrote:
A little question about the "dtml-in" tag.
What I'd like to do is to build a list according to a property value, like we can do with for "for" Python instruction, something like :
<dtml-in "object for object in objectValues() if object.visible">
Is there any way to achieve this, without writing a custom method ??
<dtml-in objectValues()> <dtml-if visible> ... </dtml-if> </dtml-in>
The problems when handling "dtml-in" in such a way are that : - you can't handle "sequence-start" or "sequence-end" correctly, when the first or last elements are not visible ; - you can't handle "dtml-else" correctly, when all the elements are not visible... :-((( Thierry
On Friday, January 24, 2003, at 09:58 AM, Thierry Florac wrote:
Is there any way to achieve this, without writing a custom method ??
<dtml-in objectValues()> <dtml-if visible> ... </dtml-if> </dtml-in>
The problems when handling "dtml-in" in such a way are that : - you can't handle "sequence-start" or "sequence-end" correctly, when the first or last elements are not visible ; - you can't handle "dtml-else" correctly, when all the elements are not visible...
Yes, that's true. So why the resistance to writing a simple script to do what you want? Any time I find myself taking more than a few seconds to think about how to do something in straight DTML or ZPT, it always turns out that I could simplify things greatly with a script. ___/ / __/ / ____/ Ed Leafe http://leafe.com/ http://opentech.leafe.com
Thierry Florac wrote at 2003-1-24 12:38 +0100:
Hi,
A little question about the "dtml-in" tag.
What I'd like to do is to build a list according to a property value, like we can do with for "for" Python instruction, something like :
<dtml-in "object for object in objectValues() if object.visible">
You want to learn about Python's list comprehension: You can use: <dtml-in expr="[object for object in objectValues() if object.visible]"> .... Precisely, what you want and very intuitive.... Dieter
participants (4)
-
Dieter Maurer -
Ed Leafe -
Maik Jablonski -
Thierry Florac