#146 Magic attributes not in dictionary returned by asDict()

open
nobody
General (125)
5
2013-01-18
2006-01-06
Jim Eggleston
No

Revision 1477: /SQLObject/trunk

'Magic' attributes created using the _get_xxx special
method are not included in the dictionary returned by
sqlmeta.asDict(). This is because the magic attributes
are not in sqlmeta.columns, which asDict uses to get
the property names.

The work around I use for now is to add the attribute
names to sqlmeta.columns explicitely. I just use a
string for the value. I have no idea what side effects
this may cause, but it makes asDict work the way i
want it to.

e.g.

class Person(SQLObject):
firstname = StringCol(length=20, default='')
lastname = StringCol(length=20, default='')
...

def _get_image(self):
...

Person.sqlmeta.columns['image'] = 'Magic attribute'

Discussion