[Zope-dev] UNEXPECTED: Acquisition.Explicit may acquire implicitly
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 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. Dieter ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: ZCatalog reindex_object
Chris Withers wrote: > > Steve Alexander wrote: > > > reindex_object is a method of the mix-in class CatalogAwareness. > > Ah, that's okay then, since Squishdot doesn't have anything to do with > CatalogAwareness. Hmm. Aren't postings CatalogAware? If they're not, shouldn't they be? Now-I'm-Curious-ly yrs, Michael Bernstein. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: [squishdot] ZCatalog reindex_object
Chris Withers wrote: > > Michael Bernstein wrote: > > > > reindex_object - should be called when an object is edited > > Hmmm... didn't see this method listed in the interfaces wiki. Where did > you find it? I found it in the 'Creating a CatalogAware ZClass' HowTo: http://www.zope.org/Members/AlexR/CatalogAware/ > I just inserted a call to catalog_object which did the job but I wonder > what the difference between index_object and reindex_object and > catalog_object is? Dunno. Sounds like a question for the main Zope list. HTH, Michael Bernstein ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZCatalog reindex_object
Steve Alexander wrote: > reindex_object is a method of the mix-in class CatalogAwareness. Ah, that's okay then, since Squishdot doesn't have anything to do with CatalogAwareness. > I think calling index_object should work, as a well-implemented catalog > will do the right thing. However, calling reindex_object makes your > intentions more explicit. AFAICT, the catalog doesn't have a recatalog_object method and the comments for catalog_object in ZCatalog.py suggest it can be used to re-cataloging and well as cataloging. ...in which case, I wonder why CatalogAwareness goes to the trouble of unindexing and then re-indexing? answers on a postcard, or email ;-) cheers, Chris ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZCatalog reindex_object
Chris Withers wrote: > Michael Bernstein wrote: > >> reindex_object - should be called when an object is edited > > > Hmmm... didn't see this method listed in the interfaces wiki. Where did > you find it? reindex_object is a method of the mix-in class CatalogAwareness. lib/python/Products/ZCatalog/CatalogAwareness.py line 191 def reindex_object(self): """ Suprisingly useful """ self.unindex_object() self.index_object() > I just inserted a call to catalog_object which did the job but I wonder > what the difference between index_object abd reindex_object and > catalog_object is? I think calling index_object should work, as a well-implemented catalog will do the right thing. However, calling reindex_object makes your intentions more explicit. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] ZCatalog reindex_object
Michael Bernstein wrote: > > reindex_object - should be called when an object is edited Hmmm... didn't see this method listed in the interfaces wiki. Where did you find it? I just inserted a call to catalog_object which did the job but I wonder what the difference between index_object abd reindex_object and catalog_object is? cheers, Chris ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )