Thread: [SQLObject] length in StringCol
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Daniel N. <no...@gm...> - 2007-01-14 14:59:52
|
Hi list, If I do ------------------------------------------------------ import sqlobject s = sqlobject.StringCol( length=10 ) s._kw[ 'length' ] ------------------------------------------------------ then I can see that the length parameter of the string column is 10. But if I do (as in real life): ------------------------------------------------------- import sqlobject class t( sqlobject.SQLObject ): s = sqlobject.StringCol( length=10 ) t.s._kw[ 'length' ] -------------------------------------------------------- then this throws an exception saying " 'property' object has no attribute '_kw' ". I guess it's because of the magic involved in class creation. In any case, how can I retrieve the length parameter of a string column of an already created table class? Or any other parameter set for any other column? |
From: Oleg B. <ph...@ph...> - 2007-01-14 16:21:38
|
On Sun, Jan 14, 2007 at 03:59:47PM +0100, Daniel Nogradi wrote: > import sqlobject > class t( sqlobject.SQLObject ): > s = sqlobject.StringCol( length=10 ) > t.s._kw[ 'length' ] > -------------------------------------------------------- > > then this throws an exception saying " 'property' object has no > attribute '_kw' ". I guess it's because of the magic involved in class > creation. Exactly. After the magic the StringCol object is converted to SOStringCol object which you have to look up as t.sqlmeta.columns['s'] Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Daniel N. <no...@gm...> - 2007-01-14 16:42:10
|
> > import sqlobject > > class t( sqlobject.SQLObject ): > > s = sqlobject.StringCol( length=10 ) > > t.s._kw[ 'length' ] > > -------------------------------------------------------- > > > > then this throws an exception saying " 'property' object has no > > attribute '_kw' ". I guess it's because of the magic involved in class > > creation. > > Exactly. After the magic the StringCol object is converted to > SOStringCol object which you have to look up as > > t.sqlmeta.columns['s'] Great, thanks very much. |