예제 #1
0
 def first_or_404(self, description=None):
     rv = self.first()
     if rv is None:
         raise NotFound()
     return rv
예제 #2
0
def get_group_all():
    '''查询所有权限组'''
    group_list = GroupModel.get_all()
    if not group_list:
        raise NotFound(msg='不存在任何权限组')
    return Success(group_list)
예제 #3
0
 def first_or_404(self, description=None):
     rv = self.first()
     if not rv:
         raise NotFound(msg=description)
     return rv
예제 #4
0
 def get_or_404(self, ident):
     rv = self.get(ident)
     if rv is None:
         raise NotFound()
     return rv
예제 #5
0
 def all(self):
     rv = list(self)
     if not rv:
         raise NotFound()
     return rv
예제 #6
0
 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
예제 #7
0
def update_user():
    user = User.query.get_or_404(g.user.uid)
    if not user:
        raise NotFound()
    return jsonify(user)
예제 #8
0
파일: base.py 프로젝트: jornsky/weiapi
 def get_or_404(self, ident):
     rv = self.get(ident)
     if not rv:
         raise NotFound()
     return rv
예제 #9
0
파일: base.py 프로젝트: Air-Zhuang/ginger
 def first_or_404(self):  #first_or_404,返回自定义异常
     rv = self.first()
     if not rv:
         raise NotFound()  #被HTTPException()捕获
     return rv
예제 #10
0
def delete(nf_id):
    nf = Notifications.get_by_id(nf_id)
    if nf is None:
        raise NotFound('找不到这个通知')
    nf.delete()
    raise Success('已删除')
예제 #11
0
파일: base.py 프로젝트: Air-Zhuang/ginger
 def get_or_404(self, ident):  #重写get_or_404,返回自定义异常
     rv = self.get(ident)
     if not rv:
         raise NotFound()  #被HTTPException()捕获
     return rv
예제 #12
0
파일: redis.py 프로젝트: genana/example-pro
 def get_uid_by_key(self, key):
     try:
         ruid = int(self.connection.hget(key, 'uid').decode('ascii'))
     except Exception:
         raise NotFound()
     return ruid
예제 #13
0
 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)
예제 #14
0
 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
예제 #15
0
def super_get_users(uid):
    user = User.query.get_or_404(uid)
    if not user:
        raise NotFound()
    return jsonify(user)
예제 #16
0
 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
예제 #17
0
 def get_or_404(self, ident):
     '''重写getor404方法,抛出自定义的API异常'''
     rv = self.get(ident)
     if not rv:
         raise NotFound()
     return rv
예제 #18
0
파일: base.py 프로젝트: jornsky/weiapi
 def first_or_404(self):
     rv = self.first()
     if not rv:
         raise NotFound()
     return rv
예제 #19
0
 def first_or_404(self):
     '''重写first抛出API异常'''
     rv = self.first()
     if not rv:
         raise NotFound()
     return rv
예제 #20
0
 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
예제 #21
0
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')
예제 #22
0
 def get_or_404(self, ident, description=None):
     rv = self.get(ident)
     if not rv:
         raise NotFound(msg=description)
     return rv
예제 #23
0
파일: base.py 프로젝트: Annihilater/ginger
 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')
예제 #25
0
파일: base.py 프로젝트: yasin007/ginger
 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
예제 #26
0
 def first_or_404(self):
     rv = self.first()
     if rv is None:
         raise NotFound()
     return rv
예제 #27
0
 def get_or_404(self, ident, description=None):
     rv = self.get(ident)
     if rv is None:
         raise NotFound()
     return rv