On Thursday 08 August 2002 03:01 am, Johan Carlsson [Torped] wrote:
Hi, I'm looking for documentation on Record.pyd, preferably the Record.py equivalent (for Zope 2.5.1).
I'm trying to figure out if it's possible to add grouping and statistics to ZCatalogs.
Best Regards, Johan Carlsson
I'm not sure the record structure is relevant to grouping. All a record is a fast and efficient way to represent data stored in a tuple (from the catalog metadata) as a python object with attributes where the attr names are mapped to the correct tuple item (column). Grouping can be done at a higher level, probably using a python sort or a dictionary. Lets say you have a record/metadata schema like so: id (string) name (string) amount (float) and you want to group by name and total the amounts, then you could use something like: totals = {} for r in records: totals[r.name] = totals.get(r.name, 0.0) + r.amount totals = totals.items() totals.sort() Which would return a list of (name, total amount) tuples sorted by name. hth, Casey