Hello, I'm trying to iterate through an list created with ObjectItems and test if each sequence item has a given property, something like: <dtml-in "objectItems(['DTML Document'])"> <dtml-if "_['sequence-item'].hasProperty('active')"> <p>This document is "active"</p> </dtml-if> </dtml-in> This isn't working though, I get Error Type: AttributeError Error Value: hasProperty any help with this greatly appreciated, Roger. _____________________________________________________________ Roger Sillito (Web Assistant) Publications & Website Development Office 0191 222 3482 University of Newcastle upon Tyne naoyam.ncl.ac.uk NE1 7RU w.r.sillito@ncl.ac.uk ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
"Roger Sillito" <w.r.sillito@ncl.ac.uk> writes:
<dtml-in "objectItems(['DTML Document'])"> <dtml-if "_['sequence-item'].hasProperty('active')">
This isn't working though, I get
Error Type: AttributeError Error Value: hasProperty
Does it work using objectValues instead of objectItems?
<dtml-in "objectItems(['DTML Document'])"> <dtml-if "_['sequence-item'].hasProperty('active')">
This isn't working though, I get
Error Type: AttributeError Error Value: hasProperty
Does it work using objectValues instead of objectItems?
Afraid not. Dieter has suggested using _.getitem() instead as this returns the object rather than rendering it (as _['..'] does) - will have a go with this. Rog.
Since objectItems is returning a list of objects, you don't need to look up sequence-item in the _ namspace. Try this instead: <dtml-if "sequence-item.hasProperty('active')"> I think what you were doing would work if you were using "objectIds" instead, which returns a list of object names. Roger Sillito wrote:
Hello, I'm trying to iterate through an list created with ObjectItems and test if each sequence item has a given property, something like:
<dtml-in "objectItems(['DTML Document'])"> <dtml-if "_['sequence-item'].hasProperty('active')"> <p>This document is "active"</p> </dtml-if> </dtml-in>
This isn't working though, I get
Error Type: AttributeError Error Value: hasProperty
any help with this greatly appreciated, Roger.
_____________________________________________________________ Roger Sillito (Web Assistant) Publications & Website Development Office 0191 222 3482 University of Newcastle upon Tyne naoyam.ncl.ac.uk NE1 7RU w.r.sillito@ncl.ac.uk ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
_______________________________________________ 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 )
Roger Sillito writes:
Hello, I'm trying to iterate through an list created with ObjectItems and test if each sequence item has a given property, something like:
<dtml-in "objectItems(['DTML Document'])"> <dtml-if "_['sequence-item'].hasProperty('active')"> <p>This document is "active"</p> </dtml-if> </dtml-in>
This isn't working though, I get
Error Type: AttributeError Error Value: hasProperty "_[...]" renders the object. This process often results in a string and strings do not have a "hasProperty" attribute.
Use "_.getitem(...)" instead. More about such issues in the "Name lookup" section of <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Dieter
participants (4)
-
Dieter Maurer -
Jens Quade -
Paul Erickson -
Roger Sillito