def __init__(self, db=None, bind=None, **options):
     if db is None:
         db = self._db
     #: The application that this session belongs to.
     self.app = db.get_app()
     self._model_changes = {}
     options.update(self._options)
     options.setdefault('autocommit', False)
     options.setdefault('autoflush', False)
     options.setdefault('binds', db.get_binds(self.app))
     #: A flag that controls whether this session should keep track of
     #: model modifications.  The default value for this attribute
     #: is set from the ``SQLALCHEMY_TRACK_MODIFICATIONS`` config
     #: key.
     self.emit_modification_signals = \
         self.app.config['SQLALCHEMY_TRACK_MODIFICATIONS']
     bind = options.pop('bind', None) or db.engine
     SessionBase.__init__(self, bind=bind, **options)
Ejemplo n.º 2
0
    def __init__(self, db, autocommit=False, autoflush=True, **options):
        self.app = db.get_app()
        self._model_changes = {}
        self.emit_modification_signals = self.app.config['SQLALCHEMY_TRACK_MODIFICATIONS']

        bind = options.pop('bind', None)
        if bind is None:
            bind = db.engine

        binds = options.pop('binds', None)
        if binds is None:
            binds = db.get_binds(self.app)

        SessionBase.__init__(self,
                             autocommit=autocommit,
                             autoflush=autoflush,
                             bind=bind,
                             binds=binds,
                             **options)
Ejemplo n.º 3
0
    def __init__(self, db, autocommit=False, autoflush=True, **options):
        self.app = db.get_app()
        self._model_changes = {}
        self.emit_modification_signals = \
            self.app.config['SQLALCHEMY_TRACK_MODIFICATIONS']

        bind = options.pop('bind', None)
        if bind is None:
            bind = db.engine

        binds = options.pop('binds', None)
        if binds is None:
            binds = db.get_binds(self.app)

        SessionBase.__init__(self,
                             autocommit=autocommit,
                             autoflush=autoflush,
                             bind=bind,
                             binds=binds,
                             **options)
Ejemplo n.º 4
0
 def ordered_answers(self):
     return SessionBase.object_session(self).query(Answer).with_parent(self).order_by(Answer.order).all()
Ejemplo n.º 5
0
 def ordered_questions(self):
     return SessionBase.object_session(self).query(Question).with_parent(self).order_by(Question.order).all()
Ejemplo n.º 6
0
 def active_questions(self):
     return SessionBase.object_session(self).query(Question).with_parent(self).filter(Question.active==True).order_by(Question.order).all()