[Zope-CMF] Programming OOP and Products

Pascal Samuzeau samuzeau@oreka.com
Sun, 17 Nov 2002 20:01:17 +0100


Hi                                                                   =20
                                                                     =20
                                                                     =20
I want to cretae a Product as :                                      =20
                                                                     =20
Class One():                                                         =20
                                                                     =20
    _properties=3D(                                                    =20
		 {'id':'title',      'type':'string',   'mode':'w'},               =20
		 {'id':'validity',   'type':'string',   'mode':'w'},               =20
             ... and so on ...                                       =20
                )                                                    =20
                                                                     =20
    def __init__( self, id, title, validity):                        =20
      self.id =3D id                                                   =20
      self.title =3D title                                             =20
      self.validity =3D validity                                       =20
      ....                                                           =20
                                                                     =20
Class Two(One):                                                      =20
                                                                     =20
    _properties=3D(                                                    =20
		 {'id':'title',      'type':'string',   'mode':'w'},               =20
                )                                                    =20
                                                                     =20
    def __init__(self,id,title)                                      =20
      One.__init__(self,id,title,=E2=80=A6)                              =
  =20
                                                                     =20
                                                                     =20
                                                                     =20
                                                                     =20
                                                                     =20
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
                                                                     =20
So :                                                                 =20
                                                                     =20
1 =E2=80=93 What is the methodology to create a such Product ?           =
  =20
2 =E2=80=93 If my conception is good, whare are my faults in my          =
  =20
programmation ?                                                      =20
                                                                     =20
Cheers                                                               =20
PS                                                                   =20
                                                                     =20
--------------------------------------------------                   =20
Oreka ! Nous sommes l'internet moins cher !                          =20
Surfez 25% moins cher avec http://www.oreka.com                      =20