def get_category_by_name(app, name):
 sa_session = app.model.context.current
 try:
  return sa_session.query(app.model.Category).filter_by(name=name).one()
 except sqlalchemy.orm.exc.NoResultFound:
  return None

def get_category_by_name ( app , name ) : sa_session = app . model . context . current try : return sa_session . query ( app . model . Category ) . filter_by ( name = name ) . one ( ) except sqlalchemy . orm . exc . NoResultFound : return None
get a category from the database via name .