[Zope] Relational queries on zope obj db?
marc lindahl
marc@bowery.com
Mon, 28 May 2001 22:50:30 -0400
> From: "Jeff Kowalczyk" <jtk@adelphia.net>
>
> A simple example would be: customer-class in one folder,
> purchaseorder-class in another, productitem-class in a third; select all
> purchase orders for customerA, displaying each individual productitem
> ordered.
Why would you have those three things in different folders? Why not, for
example have:
class Productitem:
def __init___
price = 0
itemno = 0
upc = 0
description = ''
etc....
class Purchaseorder:
def __init__
ponumber = 0
itemlist = []
shipping = 0
terms = 'net 30'
tax = 0
date = ZopeTime()
def total(self)
total = 0
for i in itemlist
total = total + i.price
total = total * (1 + self.tax) + self.shipping
return total
etc...
def Customer:
def __init__
customerid = 0
terms = 'net30'
address = ''
purchase_orders = []
etc....
So then you instantiate a customer object for each customer (customer1 =
Customer()), and each time a purchase order is made you'd instantiate one of
those and add it to the list:
customer1.purchase_orders.append(Purchaseorder())
then you could add items to the last purchase order (of course, you'd
probably want to address it by name, easily done in python, but for
simplicity...)
customer1.purchase_orders[-1].itemlist.append(Productitem())
Seems the object orientation of python makes something like this the natural
organization, as opposed to the table orientation of a so-called RDB....
Then in Zope, you'd naturally take steps to Catalog these things as they
were created, facilitating high speed searches and report generation.