http://www.sqlalchemy.org/trac/wiki/UsageRecipes/GenericOrmBaseClass

class Recall(OrmObject):pass

mapper(Recall,recall_table)

record=Recall(RECORD_ID=RECORD_ID,CAMPNO=CAMPNO,MAKETXT=MAKETXT)
session.add(record)
session.flush()

This is not working if using the example set in the url. Is setattr
still working.....? What is the proper way to do this.....for SA
0.5.6?

SQLAlchemy 0.5 Implementation:

class OrmObject(object):

    def __init__(self, **kw):
        for key in kw:
            if not key.startswith('_') and key in self.__dict__:
                setattr(self, key, kw[key])

    def __repr__(self):
        attrs = []
        for key in self.__dict__:
            if not key.startswith('_'):
                attrs.append((key, getattr(self, key)))
        return self.__class__.__name__ + '(' + ', '.join(x[0] + '=' +
                                            repr(x[1]) for x in attrs) + ')'

Thanks,
Lucas

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.


Reply via email to