listing objects based on their property?
Hi, is there any way to list contents of a directory in DTML Method based on the objects property? for example, a DTML code that will look at a certain ditectory(dtml-folder) and lists the objects that has "menu" property. ismet
On Monday 09 July 2001 17:06, Ismet Dere wrote:
Hi,
is there any way to list contents of a directory in DTML Method based on the objects property?
for example, a DTML code that will look at a certain ditectory(dtml-folder) and lists the objects that has "menu" property.
how bout <dtml-in "myfolder.objectValues()"> <dtml-if "_.hasattr(_['sequence-item'], 'menu')"> <li><a href="<dtml-var absolute_url>"><dtml-var title_or_id></a></li> </dtml-if> </dtml-in> kapil
This can be done in DTML, but you can try this python script: ## Script (Python) "list_with_attr" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=the_attr="menu" ##title= ## the_list = [] for f in container.objectValues(): if hasattr(f, the_attr): the_list.append(f) return the_list Now that you have the objects list you can use DTML to present them. ----- Original Message ----- From: "Ismet Dere" <ismet_dere@yahoo.com> To: <zope@zope.org> Sent: Tuesday, July 10, 2001 8:06 AM Subject: [Zope] listing objects based on their property?
Hi,
is there any way to list contents of a directory in DTML Method based on the objects property?
for example, a DTML code that will look at a certain ditectory(dtml-folder) and lists the objects that has "menu" property.
ismet
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
If it's sorting your thinking of, take a look at the SortEx module. Now an External Method module downloadable from www.zope.org and will be part of the Zope core in the near future I believe. Then you can SortEx(yoursequenceofobjects, (('propertysort',),)) Peter ----- Original Message ----- From: "Ismet Dere" <ismet_dere@yahoo.com> To: <zope@zope.org> Sent: Tuesday, July 10, 2001 2:06 AM Subject: [Zope] listing objects based on their property?
Hi,
is there any way to list contents of a directory in DTML Method based on the objects property?
for example, a DTML code that will look at a certain ditectory(dtml-folder) and lists the objects that has "menu" property.
ismet
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
ender -
Ismet Dere -
Li Dongfeng -
Peter Bengtsson