Dieter Maurer wrote:
By the way, it is as nasty in Python as it is in DTML.


I agree with we disagree, I hopethat doesn't cause offence ;-)

Worse still, you use hasattr with ZODB... hastattr swallows all exceptions, including ConflictErrors, and especially in this example that would be a bad thing...

Again, the correct way to approach this problem is not
to ban "hasattr" from thousands of places
but to monkey patch "__builtin__.hasattr"
such that it behaves in a Zope compatible way.

It doesn't matter what is correct and what isn't correct here, you're handing out advice that will break when a person tries it and they least expect it to break. That's not a nice thing to do...

I strongly argue against it. Fix "hasattr" in the Zope context,
instead!

Make it so! :-)
if getattr(thefolder.aq_inner.aq_explicit,the_id,None):

You are aware that this is in general *NOT* an emulation
of "hasattr".

I didn't say it was ;-)

It may fail e.g. for properties.

How would it fail for properties?

And it would be so easy to fix "hasattr" ;-)

then why haven't you done it? ;-)

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 )

Reply via email to