示例#1
0
文件: model.py 项目: bmcfee/gordon
 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)
示例#2
0
 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)
示例#3
0
    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)
示例#4
0
文件: model.py 项目: bmcfee/gordon
        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)
示例#5
0
 def mapper(cls, *arg, **kw):
     cls.query = scoped_session.query_property()
     return sa_mapper(cls, *arg, **kw)
示例#6
0
文件: npd.py 项目: jojosati/npd2
 def mapper(cls, *arg, **kw):
     cls.query = scoped_session.query_property()
     return sqla_mapper(cls, *arg, **kw)