def mapper(cls, *arg, **kw): if cls.__init__ is object.__init__: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) scoped_session.add(self) # new mapped objects will be automatically added to the session cls.__init__ = __init__ cls.query = scoped_session.query_property() return sqla_mapper(cls, *arg, **kw)
def session_mapper(cls, *args, **kwargs): if kwargs.pop('save_on_init', True): old_init = cls.__init__ def __init__(self, *args, **kwargs): old_init(self, *args, **kwargs) scoped_session.add(self) cls.__init__ = __init__ cls.query = scoped_session.query_property() return mapper(cls, *args, **kwargs)
def session_mapper(cls, *args, **kwargs): if kwargs.pop('save_on_init', True): old_init = cls.__init__ def __init__(self, *args, **kwargs): old_init(self, *args, **kwargs) scoped_session.add(self) cls.__init__ = __init__ cls.query = scoped_session.query_property() return mapper(cls, *args, **kwargs)
def mapper(cls, *arg, **kw): if cls.__init__ is object.__init__: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) scoped_session.add( self ) # new mapped objects will be automatically added to the session cls.__init__ = __init__ cls.query = scoped_session.query_property() return sqla_mapper(cls, *arg, **kw)
def mapper(cls, *arg, **kw): cls.query = scoped_session.query_property() return sa_mapper(cls, *arg, **kw)
def mapper(cls, *arg, **kw): cls.query = scoped_session.query_property() return sqla_mapper(cls, *arg, **kw)