I'm a new at this so please bear with me... I'm using a dtml-in tag to iterate through a list returned by objectValues. I want to look at each item and determine if it is a folder or a dtml-file and execute a certain action based on that information. Only problem is, I don't know what property holds that info and I've looked all over. Can anybody help? Sorry if this is a dumb question but this is driving me nuts. Jason Wertz Senior Technology Specialist / WebMaster Delaware County Community College ph: 610-325-2771 fax: 610-325-2820 http://learn.dccc.edu/~jason
This should do the trick: <dtml-in objectValues> <dtml-if "meta_type == 'Folder'"> do something </dtml-if> <dtml-if "meta_type =='DTML Method'"> do something else </dtml-if> </dtml-in> This is probably better expressed as a Python Script, but the above will work... Here's an example of a Python Script that returns a list of objects with their types: l = [] for value in context.objectValues(): l.append({'id':value.getId(), 'type':value.meta_type}) return l A DTML method to iterate over the result of this Python Script (if it were named getStuff) might look like: <dtml-in getStuff> <dtml-var id> <dtml-var type> </dtml-in> - C On Tue, 2002-08-13 at 16:07, Jason Wertz wrote:
I'm a new at this so please bear with me...
I'm using a dtml-in tag to iterate through a list returned by objectValues. I want to look at each item and determine if it is a folder or a dtml-file and execute a certain action based on that information. Only problem is, I don't know what property holds that info and I've looked all over. Can anybody help?
Sorry if this is a dumb question but this is driving me nuts.
Jason Wertz Senior Technology Specialist / WebMaster Delaware County Community College ph: 610-325-2771 fax: 610-325-2820 http://learn.dccc.edu/~jason
_______________________________________________ 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 )
One possibility would be to use the meta_type. I would not write this in DTML though, use a python script like: for ob in context.objectValues(): if ob.meta_type == 'Folder': ..do folderish things.. else: ..do non-folderish things.. Another possibility is checking for the attribute "isPrincipiaFolderish", but acquisition will likely get in your way with that, giving you false positives. Supposably aq_explicit is the cure for this, but I have not found it to be reliable: for ob in context.objectValues(): if getattr(ob.aq_explicit, 'isPrincipiaFolderish', 0): ..do folderish things.. else: ..do non-folderish things.. YMMV ;^) hth, Casey On Tuesday 13 August 2002 04:07 pm, Jason Wertz wrote:
I'm a new at this so please bear with me...
I'm using a dtml-in tag to iterate through a list returned by objectValues. I want to look at each item and determine if it is a folder or a dtml-file and execute a certain action based on that information. Only problem is, I don't know what property holds that info and I've looked all over. Can anybody help?
Sorry if this is a dumb question but this is driving me nuts.
Jason Wertz Senior Technology Specialist / WebMaster Delaware County Community College ph: 610-325-2771 fax: 610-325-2820 http://learn.dccc.edu/~jason
_______________________________________________ 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 (3)
-
Casey Duncan -
Chris McDonough -
Jason Wertz