Re: [Zope] UNEXPECTED: Acquisition.Explicit may acquire implicitly

2001-01-03 Thread Dieter Maurer

Pierre-Julien Grizel writes:
  Dieter Maurer wrote:
   
   This implies, that the idiom
   
   dtml-if "_.hasattr(o.aq_explicit,)"
   
   cannot be used safely to test, whether "o" has attribute
    itself (rather than acquired it).
   We probably should have a standard function for this kind
   of test.
  
  
  
  Mhhh  Something like "dtml-if "_.hasattr(o.aq_base,)"" ?
"aq_base" is not considered safe and unavailable in DTML.

But you are right, that would be the implementation of the
function, I call for.


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] UNEXPECTED: Acquisition.Explicit may acquire implicitly

2001-01-02 Thread Pierre-Julien Grizel

Dieter Maurer wrote:
 
 While trying to understand, what the "bself= self.aq_explicit"
 in "OFS.DTMLMethod.__call__" should do, I detected an unexpected
 behaviour:
 
 usually, this "bself" acquires implicitly from
 its container (though not from its context)
 
 More precisely:
 
 if "bself.aq_self" is itself an implicit acquisition
 wrapper, the "bself.aq_explicit" acquires implicitly
 from "bself.aq_self.aq_parent".
 
 The following Python module demonstrates the behaviour:
 
 ---
 from Acquisition import Implicit
 
 class C(Implicit): pass
 
 b= C()
 b.i= 0
 b.d= C()
 b.h= C()
 
 e_bd= b.d.aq_explicit
 try:
 e_bd.i
 print 'e_bd implicitly acquired i'
 except AttributeError: pass
 
 e_bhd= b.h.d.aq_explicit
 try:
 e_bhd.i
 print 'e_bhd implicitly acquired i'
 except AttributeError: pass
 ---
 
 At first, I thought this were a bug.
 At second thought, however, it appears to be quite
 natural, though unexpected:
 
 if o is self.__of__(parent), then
 getattr(o.aq_explicit,k) = getattr(self,k).__of__(o)
 
 If "self" is an implicit wrapper itself,
 then acquisition may be used to look up "k".
 
 This implies, that the idiom
 
 dtml-if "_.hasattr(o.aq_explicit,)"
 
 cannot be used safely to test, whether "o" has attribute
  itself (rather than acquired it).
 We probably should have a standard function for this kind
 of test.



Mhhh  Something like "dtml-if "_.hasattr(o.aq_base,)"" ?




P.-J.



 
 Dieter
 
 ___
 Zope maillist  -  [EMAIL PROTECTED]
 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 )

-- 
If the only tool you have is a hammer, 
you tend to see every problem as a nail.
Si le seul outil dont vous disposez est un marteau, 
vous avez tendance à voir chaque problème comme un clou. 
   --Abraham Maslow

___
Zope maillist  -  [EMAIL PROTECTED]
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 )