Re: [SQLObject] Thank you for the nice words (was: Bloody hell)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Kevin D. <da...@gm...> - 2006-04-19 15:24:06
|
On 4/19/06, Elver Loho <elv...@gm...> wrote: > I want to have a class that is initialised from the database. I also > want to put its definition in the same file or include the model just > once into my program. However, this is impossible as far as I know. Or > is it? Here's a workaround: def init_from_database(): global Transactions class Transactions(SQLObject): ... Then, once you have your database connection, call init_from_database in that module. It would be possible to set up SQLObject's metaclass such that initialization is deferred until the first attempt is made to use the class. But it doesn't work that way, and I'd imagine there would be some trickyness involved in making it work like that. Kevin |