Re: [SQLObject] List columns in a class
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Oleg B. <ph...@ph...> - 2010-07-22 13:46:14
|
On Thu, Jul 22, 2010 at 02:49:39PM +0200, Julien Syx wrote: > It's okay with the field name. > > I would like to have field/value. > It's okay to have field with : > > for col in rights.sqlmeta.columnList: > print "column:"+str(col.name)+ " | value:"+str(col) > > It returns to me : column:hosts_delete | value:<SOBoolCol hosts_delete> > > I tried col.value, but no way. > Have you an idea ? I didn't see docs nor exemple on web. If 'rights' is a row from the Rights table then rights.hosts_delete is the value of the column. To get the value by name use getattr(): for col in rights.sqlmeta.columnList: print "column:"+str(col.name)+ " | value:"+str(getattr(rights, col.name)) Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |