what u mean by "working"? if the object's __init__ is not called when loaded from db (like pickle) - see docs for other hooks.
http://www.sqlalchemy.org/docs/05/mappers.html#constructors-and-object-initialization e.g. the @orm.reconstructor decorator On Saturday 21 February 2009 10:28:23 laurent FRANCOIS wrote: > Hello > > Is it obvious that this model: > > > %%%%%%%%%%%%%%%%% > ##Class Table > user_table = Table( > 'user', metadata, > Column('user_id', Integer, > primary_key=True), Column('fname', Unicode(50), default=''), > Column('lname', Unicode(50), default='') ) > ## Class ORM > class User(object): > u"""User model""" > def __init__(self,dic): > """Set instance attribut with a dictionnary > dico= {'fname': 'value1', 'lname': 'value2'} > instance = User(dico) > """ > > > self.listfieldname = dic.keys() > self.dic = dic > > for key in dic: > setattr(self,key,dic[key]) > def __repr__(self): > return '<%s %s>' %(self.dic[self.listfieldname[0]], > self.dic[self.listfieldname[1]]) > > mapper(User, user_table) > > %%%%%%%%%%%%%%%%%%%%%% > > doesn't work for a session.query(User).all() > but work fine for session.add(User(dico)) > ??? > > Thanks > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---