Example #1
0
 def get(self, id):
     try:
         obj = self._session.query(self.model).filter(self.model.id == id)\
                                              .first()
         return _extract_selections(obj, self.model_selections)
     finally:
         self._session.close()
         db.engine.dispose()
Example #2
0
 def get(self, id):
     try:
         obj = self._session.query(self.model).filter(self.model.id == id)\
                                              .first()
         return _extract_selections(obj, self.model_selections)
     finally:
         self._session.close()
         db.engine.dispose()
Example #3
0
    def filter_by_id(self, recipe_id):

        obj = self._session.query(Recipe)\
                  .filter(self.model.id == recipe_id).first()

        selections = _extract_selections(obj, self.model_selections)

        self._session.close()

        return selections
Example #4
0
    def _list(self, model=None, selections=None, limit=50, query=None):
        model = model or self.model
        selections = selections or self.model_selections

        if query is None:
            query = self._session.query(model)

        if limit is not None:
            query = query.limit(limit)

        try:
            objects = query.all()
            return _extract_selections(objects, selections)
        finally:
            self._session.close()
            db.engine.dispose()
Example #5
0
    def _list(self, model=None, selections=None, limit=50, query=None):
        model = model or self.model
        selections = selections or self.model_selections

        if query is None:
            query = self._session.query(model)

        if limit is not None:
            query = query.limit(limit)

        try:
            objects = query.all()
            return _extract_selections(objects, selections)
        finally:
            self._session.close()
            db.engine.dispose()