Hi List:
I was wondering if it is possible to use automatic class generation =
(http://sqlobject.sourceforge.net/docs/SQLObject.html#automatic-class-gen=
eration) and pass a database connection object in at the time of =
instance creation. I was thinking something along the lines of:
from objects import Trial
u =3D Trial.new(_connection=3Dreq.conn, userName=3D"WUMPUS")
content =3D u.userName
where Trial is:
from SQLObject import *
class Trial(SQLObject):
_fromDatabase =3D True
When I try this I'm getting an error indicating that there is no =
connection object yet:=20
File "/<path>/SQLObject.py", line 523, in addColumnsFromDatabase
for columnDef in cls._connection.columnsFromSchema(cls._table, cls):
AttributeError: 'NoneType' object has no attribute 'columnsFromSchema'
If I set Trial to:
from SQLObject import *
class Trial(SQLObject):
userName =3D StringCol()
every thing seems to work ok, so I don't think its a problem with the =
connection. It does take automatic class generation out of the picture =
though. Maybe something to do with the order things are initialized? I =
suppose that ultimately I should define my classes manually, so maybe =
its no big deal.
Also, I noticed that SQLObject.new() method accepts the connection as a =
keyword argument, but the standard constructor will only accept it as =
the second argument? i.e. u =3D Trial(1, req.conn) Is there a more =
consistent way to pass the connection to various creation methods?
Thanks in advance...
-Charles |