Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Dieter Maurer wrote: Dmitry Vasiliev wrote at 2006-5-23 17:06 +0400: ... PEP-3100 suggest "just call the object and catch the exception" instead of use "callable()". So maybe we can write: try: ob() except: pass return ob Unfortunately exceptions still will be masked. Yes, and therefore *NEVER* do this. I don't like it also but the PEP suggest so... :-) -- Dmitry Vasiliev (dima at hlabs.spb.ru) http://hlabs.spb.ru ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Dmitry Vasiliev wrote at 2006-5-23 17:06 +0400: > ... >PEP-3100 suggest "just call the object and catch the exception" instead of use >"callable()". So maybe we can write: > >try: > ob() >except: > pass >return ob > >Unfortunately exceptions still will be masked. Yes, and therefore *NEVER* do this. -- Dieter ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Philipp von Weitershausen wrote at 2006-5-23 17:02 +0200: > ... >callable() isn't even deprecated yet, so if it solves our problem, we >can use it IMO. Note that Zope 3 deliberately doesn't use it because of >the proxy problem. Zope 2 works around that by stripping >proxies/wrappers first (ob.aq_base). Perhaps Zope3 should do that as >well. Would callable(removeAllProxies(obj)) be harmful in any way if you >end up calling the proxied obj() anyway? At least earlier, "callable" had a problem: some objects where apparently "callable" but calling them resulted in "AttributeError: __call__". That's why "cDocumentTemplate" grew a "safe_callable". -- Dieter ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Philipp von Weitershausen wrote: (Which is, btw, why I prefer direct imports and dislike zapi nowadays: it doesn't make clear what a particular API the function comes from). For that and other reasons: death to zapi! -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Dmitry Vasiliev wrote: try: ob() except: pass Please god, no bare excepts! Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Stephan Richter wrote: > On Tuesday 23 May 2006 11:02, Philipp von Weitershausen wrote: >> Would callable(removeAllProxies(obj)) be harmful in any way if you >> end up calling the proxied obj() anyway? > > No, we do this for zapi.isinstance as well. Well, yeah, zapi.isinstance really is from zope.security.proxy.isinstance. This means it only strips security proxies. (Which is, btw, why I prefer direct imports and dislike zapi nowadays: it doesn't make clear what a particular API the function comes from). I would be removing ALL proxies (because that's what it takes to make callable()'s result accurate). Philipp ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
On Tuesday 23 May 2006 11:02, Philipp von Weitershausen wrote: > Would callable(removeAllProxies(obj)) be harmful in any way if you > end up calling the proxied obj() anyway? No, we do this for zapi.isinstance as well. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Dmitry Vasiliev wrote: > Philipp von Weitershausen wrote: >> Hi there, >> >> I've filed an issue in the collector outlining a problem with old style >> classes and TALES traversal: http://www.zope.org/Collectors/Zope3-dev/635 >> >> In particular, I'm looking for comments on problem #2. > > PEP-3100 suggest "just call the object and catch the exception" instead > of use "callable()". So maybe we can write: > > try: > ob() > except: > pass > return ob > > Unfortunately exceptions still will be masked. Yes. I honestly have no clue what the authors of this part of PEP3000 were thinking. Even if you only catch AttributeError, you'll never be sure the AttributeError is from the missing __call__ or from inside it. callable() isn't even deprecated yet, so if it solves our problem, we can use it IMO. Note that Zope 3 deliberately doesn't use it because of the proxy problem. Zope 2 works around that by stripping proxies/wrappers first (ob.aq_base). Perhaps Zope3 should do that as well. Would callable(removeAllProxies(obj)) be harmful in any way if you end up calling the proxied obj() anyway? Philipp ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] TALES PathExpr doesn't call old style classes
Philipp von Weitershausen wrote: Hi there, I've filed an issue in the collector outlining a problem with old style classes and TALES traversal: http://www.zope.org/Collectors/Zope3-dev/635 In particular, I'm looking for comments on problem #2. PEP-3100 suggest "just call the object and catch the exception" instead of use "callable()". So maybe we can write: try: ob() except: pass return ob Unfortunately exceptions still will be masked. -- Dmitry Vasiliev (dima at hlabs.spb.ru) http://hlabs.spb.ru ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] TALES PathExpr doesn't call old style classes
Hi there, I've filed an issue in the collector outlining a problem with old style classes and TALES traversal: http://www.zope.org/Collectors/Zope3-dev/635 In particular, I'm looking for comments on problem #2. Philipp ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com