The declarative extension (sqlalchemy.ext.declarative) provides a
__init__ that takes keyword args for attributes (at least it does in
0.4).
On Tue, Jan 13, 2009 at 4:02 AM, Christoph Haas em...@christoph-haas.de wrote:
Thanks for the code. For those who might also be interested in an ORM base
Thanks for the code. For those who might also be interested in an ORM base
class providing __init__, update and __repr__ - this is what I use now with
0.5 (comments welcome):
=
import sqlalchemy as sql
from sqlalchemy import orm
class
def __init__( me, **ka):
for k,v in ka.iteritems(): setattr( me,k,v)
def update( me, ka):
for k,v in ka.iteritems(): setattr( me,k,v)
generic repr/str is more tricky... one way is like:
for p in object_mapper(self).iterate_properties:
print getattr( self, p.key)
or was