Previous Chapter | Up | Next Section | Contents

Database Method Classes


It is possible to assign a class to the records returned by a Database Method. This class is a Python6 class defined in a Python file located in the Extensions directory 7 of the Zope installation being considered.

Classes can be used to augment otherwise static records returned from a database query with more interesting behavior. For example consider the following class definition (in a file called hardware.py located in the Extensions directory of the current Zope installation):

class ComputerHardwareItem:

def dollar_volume_backordered(self):

return unit_price * backordered

By virtue of assigning the ComputerHardwareItem class to this Database Method we now have access to the dollar_volume_backordered function for each record returned by the query. We can now refer to the dollar_volume_backordered DTML variable inside an iteration over query results.

 

Previous Chapter | Up | Next Section | Contents