[DB-SIG] How to *you* access your database objects?

Eivind Tagseth eivindt@multinet.no
Wed, 16 Oct 2002 15:29:29 +0200


* Kevin Jacobs <jacobs@penguin.theopalgroup.com> [021016 12:20]:
> On Wed, 16 Oct 2002, Eivind Tagseth wrote:
> > But what do you actually do with the data you retrieve.  And how do you
> > retrieve it?
> 
> A simple question... a rather long and complex answer.
> 
> We use the following components:
> 
>   1) A database row object that supports tuple, dictionary and object-like
>      access.  It is implemented without allocating a dictionary per-object
>      using some of the new Python 2.2 (and 2.3) features.  See 'dbrow' on
> 
>         http://opensource.theopalgroup.com/
> 
>      for details on a very early version of this concept.  Our current
>      version has evolved far beyond that, and is implemented in both Python
>      and as a C extension module, so there is effectively no performance
>      hit compared to returning rows as tuples.

Great stuff.  This fits quite well into my line of thought as well, and
exchanging my UserDict-based class with db_row was really simple.

The db_row-generated classes works pretty much like a dictionary
(i.e. I can to object['attribute']), but not completely.  Is there any
special reason why not all dictionary methods are compatible with
dictionaries?  That is, why _items(), _keys(), _values() and _has_key() 
rather than items(), keys(), values() and has_key()?



Eivind