[Zope-dev] Re: [Zope] ExtensionClass

Jim Fulton jim@digicool.com
Mon, 20 Mar 2000 14:04:10 -0500


cpita wrote:
> 
> Hi!
> 
> I have an ExtensionClass(es) question and, being the
> latest releases of them distributed with Zope, I
> decided to ask it here.

OK, let's move this to zope-dev.

> Situation:
> 
> 1) Class A subclasses 2+ extension classes E =
> {E1,...,En} and perhaps another non extension classes C
> = {C1,...,Cm}. That is, class A(B1,...,Bk): ...., where
> B1,...,Bk are each in E or in C.
> 2) a is an instance of A (a = A())
> 3) a.foo(bar) is invoked
> 4) getattr is invoked in the first extension class in
> the inherited classes list (i.e. the first Bi belonging
> to E)
> 
> Question:
> 
> What happens then?
> I guess that calling Py_FindMethod (inside getattr
> implementation) will trigger a search in instance and
> base classes' dictionaries, but what about the other
> extension base classes and what about the searching
> order?
> I can't find any doc on these, so I'm needing your help.

The search order is:

  1. Instance dictionary

  2. Class dictionary

  3. Do depth-first search of base classes from left to right.
  
In other words, the search order is the same as for getattr
on Python instances, except that some base classes can be in C.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.