autoadd class properties

manstey manstey at csu.edu.au
Fri Dec 8 19:01:04 EST 2006


Hi,

Cache is a pure OO dbase, so no ORM is required. Cache provides a
python equivalent for the Cache class, but not for the Cache
properties. Instead, the programmer has to know in advance the
properties and their type to get and set them. I want to wrap the
Python-cache class and add the Cache properties into the class, but I
don't know how to do this. Any ideas?



George Sakkis wrote:
> manstey wrote:
>
> > I have a ClassWrapper that wraps around a third party database object.
> > Each database object has a set of properties, like columns in a
> > relational database.
> >
> > I want my wrapper to generate a property for each database object and
> > load its value into it.
> >
> > Thus, in my database (which is an oodbms) say I have a MyDbaseClass
> > with MyProperty1, MyProperty2, etc, after it is loaded, I have:
> >
> > dbase_object = LoadMyDbaseClass
> > PythonDbaseClass = PythonWrapper(dbase_object)
> >
> > I can then load in a list of ['MyProperty1','MyProperty2', etc].
> >
> > But how can I turn these list elements into PythonDbaseClass
> > properties, so that I could then simply have:
> >
> > print PythonDbaseClass.MyProperty1
> > PythonDbaseClass.MyProperty2="4"
> >
> > Is this clear?
>
> Sounds as if you're reinventing a part of an ORM. Have you checked out
> SQLAlchemy or Django's ORM, in case they provide what you want out of
> the box ?
> 
> George




More information about the Python-list mailing list