def get_user(username): """ Returns the User object from the model. :rtype: :class:`inphosite.model.User` """ user = Session.query(User).filter_by(username=username.lower()).first() return user
def get_user(username): """ Returns the User object from the model. :rtype: :class:`inphosite.model.User` """ user = Session.query(User).filter_by(username=username.lower()).first() return user
def fetch_obj(type, id, error=404, new_id=False): """ Fetches the object with the given id from the collection of type type. If the object does not exist, throw an HTTP error (default: 404 Not Found). :param type: object type :type type: class in :mod:`inphosite.model` :param id: object id :type id: integer or None :param error: HTTP error code. :rtype: *type* """ if id is None: abort(error) obj_q = Session.query(type) obj = obj_q.get(int(id)) #else: # obj = obj_q.filter(type.ID==int(id)).first() if obj is None: abort(error) return obj
def fetch_obj(type, id, error=404, new_id=False): """ Fetches the object with the given id from the collection of type type. If the object does not exist, throw an HTTP error (default: 404 Not Found). :param type: object type :type type: class in :mod:`inphosite.model` :param id: object id :type id: integer or None :param error: HTTP error code. :rtype: *type* """ if id is None: abort(error) obj_q = Session.query(type) obj = obj_q.get(int(id)) #else: # obj = obj_q.filter(type.ID==int(id)).first() if obj is None: abort(error) return obj