[Zope-CMF] Programming OOP and Products

Dieter Maurer dieter@handshake.de
Mon, 18 Nov 2002 19:29:00 +0100


Pascal Samuzeau writes:
 > I want to cretae a Product as :                                      =20
 >                                                                      =20
 > Class One():                                                         =20
 >   _properties =3D ...

This is invalid syntax.

In order to play well in the Zope context, "One" should inherit
from some Zope base classes.

 > ...
 >                                                                      =20
 > Class Two(One):                                                      =20
 >   _properties =3D ...
 > ...
 > Now I have some questions about the Object Two.                      =20
 >                                                                      =20
 > By the object inheritance, I can get the value of the Two.validity,  =20
 > just because it belongs from One ( i.e : Two.validity is the value of=20
 > One.validity).                                                       =20
 >                                                                      =20
 >                                                                      =20
 > It means I create a Product A. Then in this Product I am able to     =20
 > create a Product B, but where some characteristics are in the Product=20
 > A.                                                                   =20
 >                                                                      =20
 > I want to get the properties of the Product B, with some dtml-in     =20
 > facilities, but In this way , I am not able to get the =C2=AB validity=
 =C2=BB=20
 > because it=E2=80=99s not in the same space, I think.                  =
     =20
You have several options:

  *  redefine "hasProperty" (and probably other methods of
     "PropertyManager") in class "Two".

  *  Have in class "Two",

       _properties=3D A._properties + (
         ...
	 )

     i.e. extend your properties explicitely.

     This is easier than the first approach.


Dieter