[Zope-dev] Record.pyd

Johan Carlsson [Torped] johanc@torped.se
Thu, 08 Aug 2002 15:22:40 +0200


At 09:07 2002-08-08 -0400, Casey Duncan said:
>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 =3D {}
>for r in records:
>     totals[r.name] =3D totals.get(r.name, 0.0) + r.amount
>totals =3D totals.items()
>totals.sort()
>
>Which would return a list of (name, total amount) tuples sorted by name.


Thanks for the input Casey.
(I'm still curious about Record.pyd, its not the first time I have wondered=
=20
what it does inside :-)

Would your example scale well. I suppose it's not very Lacy?

I envision a brain that would represent a group of records with methods
for calculate statistical data when needed.

Well, it's something I need to think more about anyway.

Best Regards,
Johan Carlsson




--=20
Torped Strategi och Kommunikation AB
Johan Carlsson
johanc@torped.se

Mail:
Birkagatan 9
SE-113 36  Stockholm
Sweden

Visit:
V=E4stmannagatan 67, Stockholm, Sweden

Phone +46-(0)8-32 31 23
Fax +46-(0)8-32 31 83
Mobil +46-(0)70-558 25 24
http://www.torped.se
http://www.easypublisher.com