Re: [SQLObject] a third way of accessing attributes
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Nick <ni...@dd...> - 2003-05-15 15:24:21
|
On Thu, 2003-05-15 at 10:19, Nick wrote: > On Thu, 2003-05-15 at 07:38, Bud P.Bruegger wrote: > > Some time ago, Nick and Ian (and others?) discussed about two ways of > > exposing SQL data through object attributes: > > > > * metaclasses (current SQLObject) that set properties > > * __getattr__ and __setattr__ > > > > There seems to be a third way: > > > > * Adding methods and properties (attributes) to a class at runtime > > (sans metaclasses). > > The problem with this approach is that you won't be able to > automatically resolve foreign keys at access time unless the method for > accessing foreign keys is only handled through methods, which both > __getattr__ and properties do. Sorry, I forgot to say what my point was :) My point is that it's more convenient to treat objects as persistent using that kind of model than have set() and get() functions a la C (java, etc.). You're doing nearly the exact same thing as properties, so why not use them. Nick |