[Zope] Accessing parent's methods/attrs from a child object

Chad Nantais chad_lists@rednaxel.com
Wed, 9 Apr 2003 14:49:04 -0700


I have a container objectManager called 'Vehicle'.
'Repair', which is a simpleItem, is stored inside a Vehicle instance.

When a Repair is created or edited, it should update the containing 
Vehicle's odometer reading by calling updateOdometer(newreading) on the 
Vehicle it is belongs to.  I tried adding 
self.aq_parent.updateOdometer(newReading) to Repair.py's update method.

<code>

     def update(self, number=None, date=None, odometer=None, 
REQUEST=None):
         ''' Update repair properties '''

         if number is not None:	self._number = number
         if date is not None:
             try: 		self._date = date.year + '-' + date.month + '-' + 
date.day
             except:	self._date = date
         if odometer is not None:
             self._odometer = int(odometer)
             self.aq_parent.updateOdometer(self._odometer)

</code>

The result was an attribute error (updateOdometer).

Am I misusing aq_parent in this context?  Basically, I need to know how 
to access methods and attributes of the parent object from within a 
child class.

Thanks in advance.

Chad