Hello, if I have a folder1 in a folder2 and my folder 1 has a certain property. If I want to know if folder2 has the property I use hasattr() method on folder2, but it returns true because it looks down the hierarchy and sees the property in folder1. is there a way to check for the property in folder2 ONLY without checking the ancestor folders?. Thanks! __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
Alex Renier wrote:
Hello, if I have a folder1 in a folder2 and my folder 1 has a certain property. If I want to know if folder2 has the property I use hasattr() method on folder2, but it returns true because it looks down the hierarchy and sees the property in folder1. is there a way to check for the property in folder2 ONLY without checking the ancestor folders?.
Thanks!
__________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zo
context.aq_inner.aq_self
http://zopelabs.com/cookbook/1002891491 2005/10/4, Alex Renier <goldenray3458@yahoo.com>:
Hello, if I have a folder1 in a folder2 and my folder 1 has a certain property. If I want to know if folder2 has the property I use hasattr() method on folder2, but it returns true because it looks down the hierarchy and sees the property in folder1. is there a way to check for the property in folder2 ONLY without checking the ancestor folders?.
Thanks!
__________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
Alex Renier wrote:
Hello, if I have a folder1 in a folder2 and my folder 1 has a certain property. If I want to know if folder2 has the property I use hasattr() method on folder2,
Just a note in passing, hasattr is very dangerous to use in a Zope 2 context... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
2005/10/4, Chris Withers <chris@simplistix.co.uk>:
Alex Renier wrote:
Hello, if I have a folder1 in a folder2 and my folder 1 has a certain property. If I want to know if folder2 has the property I use hasattr() method on folder2,
Just a note in passing, hasattr is very dangerous to use in a Zope 2 context...
Not sure what it's called in Page Templates or Python Scripts but in DTML it's called careful_hasattr() which wraps hasattr() in a restricted context. I'm sure TALES and Python Scripts too.
Chris
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
Peter Bengtsson wrote:
Not sure what it's called in Page Templates or Python Scripts but in DTML it's called careful_hasattr() which wraps hasattr() in a restricted context.
I wouldn't trust that either ;-) hasattr's insane in that it catches prettymuch all exception, including ConflictErrors... I much prefer get patterns of getattr(something,'something',None) or variants thereof, depending on the situation... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
2005/10/5, Chris Withers <chris@simplistix.co.uk>:
Peter Bengtsson wrote:
Not sure what it's called in Page Templates or Python Scripts but in DTML it's called careful_hasattr() which wraps hasattr() in a restricted context.
I wouldn't trust that either ;-)
hasattr's insane in that it catches prettymuch all exception, including ConflictErrors...
Didn't know that.
I much prefer get patterns of getattr(something,'something',None) or variants thereof, depending on the situation...
careful_hasattr() uses a getattr() to test if it works and does this in a restricted manner. -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (4)
-
Alex Renier -
Chris Withers -
Peter Bengtsson -
robert rottermann