def first_or_404(self, description=None): rv = self.first() if rv is None: raise NotFound() return rv
def get_group_all(): '''查询所有权限组''' group_list = GroupModel.get_all() if not group_list: raise NotFound(msg='不存在任何权限组') return Success(group_list)
def first_or_404(self, description=None): rv = self.first() if not rv: raise NotFound(msg=description) return rv
def get_or_404(self, ident): rv = self.get(ident) if rv is None: raise NotFound() return rv
def all(self): rv = list(self) if not rv: raise NotFound() return rv
def search_by_project(self, project_id): url = self.project_url.format(project_id) result = HTTP.get(url) if result == {}: raise NotFound(msg='未找到研究中心信息') return result
def update_user(): user = User.query.get_or_404(g.user.uid) if not user: raise NotFound() return jsonify(user)
def get_or_404(self, ident): rv = self.get(ident) if not rv: raise NotFound() return rv
def first_or_404(self): #first_or_404,返回自定义异常 rv = self.first() if not rv: raise NotFound() #被HTTPException()捕获 return rv
def delete(nf_id): nf = Notifications.get_by_id(nf_id) if nf is None: raise NotFound('找不到这个通知') nf.delete() raise Success('已删除')
def get_or_404(self, ident): #重写get_or_404,返回自定义异常 rv = self.get(ident) if not rv: raise NotFound() #被HTTPException()捕获 return rv
def get_uid_by_key(self, key): try: ruid = int(self.connection.hget(key, 'uid').decode('ascii')) except Exception: raise NotFound() return ruid
def get_by_id(self, book_id): url = self.bookid_url.format(book_id) result = HTTP.get(url) if not result: raise NotFound(msg='book not found') self.__fill_single(result)
def get_or_404(self, ident, e=None, error_code=None, msg=None): rv = self.get(ident) # 查询主键 if not rv: self.__abort_by_error(e) raise NotFound(error_code=error_code, msg=msg) return rv
def super_get_users(uid): user = User.query.get_or_404(uid) if not user: raise NotFound() return jsonify(user)
def all_or_404(self, e=None, error_code=None, msg=None, wrap=''): rv = list(self) if not rv: self.__abort_by_error(e) raise NotFound(error_code=error_code, msg=msg) return {wrap: rv} if wrap else rv
def get_or_404(self, ident): '''重写getor404方法,抛出自定义的API异常''' rv = self.get(ident) if not rv: raise NotFound() return rv
def first_or_404(self): rv = self.first() if not rv: raise NotFound() return rv
def first_or_404(self): '''重写first抛出API异常''' rv = self.first() if not rv: raise NotFound() return rv
def search_by_center(self, center_id): url = self.center_url.format(center_id) result = HTTP.get(url) if result == {}: raise NotFound(msg='未找到研究中心信息') return result
def delete_contest_api(id_): contest = Contest.get_by_id(id_) if not contest: raise NotFound() Contest.delete_contest(id_) return DeleteSuccess('Delete team success')
def get_or_404(self, ident, description=None): rv = self.get(ident) if not rv: raise NotFound(msg=description) return rv
def get_or_404(self, k): rv = self.get(k) if not rv: raise NotFound() return rv
def delete_announcement_api(id_): announcement = Announcement.get_by_id(id_) if not announcement: raise NotFound() Announcement.delete_announcement(id_) return DeleteSuccess('Delete announcement success')
def first_or_404(self, msg='the resource are not found O__O...'): rv = self.first() if not rv: raise NotFound(msg=msg) return rv
def first_or_404(self): rv = self.first() if rv is None: raise NotFound() return rv
def get_or_404(self, ident, description=None): rv = self.get(ident) if rv is None: raise NotFound() return rv