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? 6 1379
At Friday 8/12/2006 05:38, manstey wrote:
>Is this clear?
I'm sorry, not for me. Some code showing how things are used now and
how you would like it to be, would help.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
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
We've looked at them a little. Cache is a native OO dbase, so there is
no ORM required. Cache does that for you behind the scenes if you need
it to. What I want is to translate Cache classes and properties into
Python classes and properties. We can only use class wrappers, because
cache uses old style python objects, but this still works.
Because I am not an experienced programmer, the problem I face is how
to load ANY Cache class, whose properties the wrapper doesn't know in
advance, and turn the class properties into python properties.
So in Cache, I might have Name = String, Age = Integer, Colours = List,
in the class Person. The python binding provided by Cache creates a
Person class in Python, but it provides none of its properties, so I
want to write a wrapping class that adds the properties. Can you advise
me on how to do this?
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
manstey wrote:
We've looked at them a little. Cache is a native OO dbase, so there is
no ORM required. Cache does that for you behind the scenes if you need
it to. What I want is to translate Cache classes and properties into
Python classes and properties. We can only use class wrappers, because
cache uses old style python objects, but this still works.
Because I am not an experienced programmer, the problem I face is how
to load ANY Cache class, whose properties the wrapper doesn't know in
advance, and turn the class properties into python properties.
So in Cache, I might have Name = String, Age = Integer, Colours = List,
in the class Person. The python binding provided by Cache creates a
Person class in Python, but it provides none of its properties, so I
want to write a wrapping class that adds the properties. Can you advise
me on how to do this?
I'm afraid not, at least not without seeing an example. By the way,
I've never heard of Cache before and its name is too generic for
looking it up online; you should at least provide a link if you're
asking for help about obscure packages.
George
On 8 dic, 20:59, "manstey" <mans...@csu.edu.auwrote:
We've looked at them a little. Cache is a native OO dbase, so there is
no ORM required. Cache does that for you behind the scenes if you need
it to. What I want is to translate Cache classes and properties into
Python classes and properties. We can only use class wrappers, because
cache uses old style python objects, but this still works.
Because I am not an experienced programmer, the problem I face is how
to load ANY Cache class, whose properties the wrapper doesn't know in
advance, and turn the class properties into python properties.
So in Cache, I might have Name = String, Age = Integer, Colours = List,
in the class Person. The python binding provided by Cache creates a
Person class in Python, but it provides none of its properties, so I
want to write a wrapping class that adds the properties. Can you advise
me on how to do this?
Still unclear... Don't you have a way to iterate over all the
properties? Have you tried using dir() on the generated class?
BTW, do you know ZODB? It's an OO database written in Python and mostly
transparent for the user. You just write and use your objects as always
and the persistence mechanism does the rest.
--
Gabriel Genellina This discussion thread is closed Replies have been disabled for this discussion. Similar topics
21 posts
views
Thread by Jon Slaughter |
last post: by
|
7 posts
views
Thread by Baski |
last post: by
|
9 posts
views
Thread by David A. Osborn |
last post: by
|
3 posts
views
Thread by Simon Hart |
last post: by
|
8 posts
views
Thread by Per Bull Holmen |
last post: by
|
5 posts
views
Thread by Rainer Queck |
last post: by
|
17 posts
views
Thread by David C. Ullrich |
last post: by
|
4 posts
views
Thread by FullBandwidth |
last post: by
|
4 posts
views
Thread by Josh Valino |
last post: by
| | | | | | | | | | |