[Zope] Methods - inheritence vs acquisition

Michel Pelletier michel@digicool.com
Wed, 08 Mar 2000 02:29:46 -0800


Cary O'Brien wrote:
 
> 1)  What is the algorithm for determining which method to call?  The
>     DTML documentation says
> 
>   "attributes, including inherited and
>    acquired attributes, of the client passed
>    in the call to the document template are searched"
> 
>    But in what order?   There can be an index_html in the class, in a parent
>    class, or somewhere up the acquisition tree.  Which takes precedence?

The first two follow standard python rules, first instance attributes,
then shared instance (class) attributes, then any base class
attributes.  THEN acquisition.

>    Does the product that a ZClass have anything to do with the search?

No.

>    What about Z-Super-Classes?

Same rules.  First the instance of the ZClass attributes, then shared
instance (ZClass) attributes, then any base (Z)Class attributes.  THEN
Acquisition.

>  Inquiring minds want to know.
> 
> 1a) Why can't I have a method in a ZClass, but then override it in
>    the instance? 

I think your confused but I'm not sure.  If your ZClass is a container
(subclasses ObjectManager) then instances of that class can contain
sub-objects (attributes) with names that are managable by the Zope
managment interface.  The managment interface will NOT however let you
create a sub-object in that container that conflicts with the name of an
existing attribute *including shared instance attributes like methods of
YOUR ZClass*.  Methods of a ZClass may look like sub-objects in a
container instance, but that are not, they are shared attributes of a
class, and all instances of that class will share those attributes. 
Now, this is a limitation/feature of the managment interface, it is not
a limitation of python.  If you want to assign an attribute to an
instance in python that has the same name as a shared instance
attribute, then that instance attribute will override the shared
instance attribute.

> I.E. (Gaak, it has been a while since I've had to
>    even think about C++) virtual methods?  (Or have I got that wrong).

I don't know C++.
 
> 2) It seems that the examples require the user to generate forms by
>    hand, which seems unnecessary.  For example, (after a protracted
>    struggle with the underlying python code) I wrote a method that would
>    create an html table for any query, ripping the column names and data
>    out of the result object.

Ok.  You're talking about SQL Methods?
 
>    2.1) Shouldn't this be a standard part of Zope?

If you're talking about SQL Methods or other objects that implement the
Zope Search Inteface then it is allready a standard part of Zope.

>    2.2) If so, do you want this code?

You should look at what is there first and tell us how to improve it.

>    2.2) Likewise for property edit forms.  I did find some DTML that
>         would do this, but shouldn't this be standard.

The managment interface obviously builds the property view dynamicly, so
something like this is in Zope.  Whether or not it is useful to others
is unknown to me.

-Michel