def get_from_database(): session = DBSession() try: devices = session.query(cls).order_by(cls.name).all() except: devices = None return devices
def get_from_database(): session = DBSession() try: file = session.query(cls).filter(cls.filename == filename).one() except NoResultFound: file = None return file
def get_by_name(cls, name): session = DBSession() try: device = session.query(cls).filter(cls.name == name).one() except: device = None return device
def get_from_database(): session = DBSession() try: file = session.query(cls).filter( cls.filename == filename).one() except NoResultFound: file = None return file
def get_from_database(): session = DBSession() query = session.query(cls) if device is not None: query = query.select_from(join(File, Device)). \ filter(Device.name == device) if type is not None: query = query.filter(cls.type == type) # Limit the query and order it query = query.order_by(desc(cls.date_created))[:20] return query
def __call__(self, environ, start_response): session = DBSession() try: return self.app(environ, start_response) except: session.rollback() finally: session.close() DBSession.remove()