当前位置: 首页>>代码示例>>Python>>正文


Python api.abort函数代码示例

本文整理汇总了Python中udata.api.api.abort函数的典型用法代码示例。如果您正苦于以下问题:Python abort函数的具体用法?Python abort怎么用?Python abort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了abort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: put

 def put(self, org):
     """Update a organization given its identifier"""
     if org.deleted:
         api.abort(410, "Organization has been deleted")
     EditOrganizationPermission(org).test()
     form = api.validate(OrganizationForm, org)
     return form.save()
开发者ID:javanna2000,项目名称:udata,代码行数:7,代码来源:api.py

示例2: put

 def put(self, reuse):
     '''Update a given reuse'''
     if reuse.deleted:
         api.abort(410, 'This reuse has been deleted')
     ReuseEditPermission(reuse).test()
     form = api.validate(ReuseForm, reuse)
     return form.save()
开发者ID:anukat2015,项目名称:udata,代码行数:7,代码来源:api.py

示例3: delete

 def delete(self, org):
     '''Delete a organization given its identifier'''
     if org.deleted:
         api.abort(410, 'Organization has been deleted')
     EditOrganizationPermission(org).test()
     org.deleted = datetime.now()
     org.save()
     return '', 204
开发者ID:opendatateam,项目名称:udata,代码行数:8,代码来源:api.py

示例4: put

 def put(self):
     '''Set the homepage datasets editorial selection'''
     if not isinstance(request.json, list):
         api.abort(400, 'Expect a list of dataset IDs')
     ids = [ObjectId(id) for id in request.json]
     Site.objects(id=current_site.id).update(set__settings__home_datasets=ids)
     current_site.reload()
     return current_site.settings.home_datasets
开发者ID:guillo-w,项目名称:udata,代码行数:8,代码来源:api.py

示例5: put

 def put(self, reuse):
     '''Update a given reuse'''
     request_deleted = request.json.get('deleted', True) 
     if reuse.deleted and request_deleted is not None: 
         api.abort(410, 'This reuse has been deleted')
     ReuseEditPermission(reuse).test()
     form = api.validate(ReuseForm, reuse)
     return form.save()
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:api.py

示例6: delete

 def delete(self, org):
     """Delete a organization given its identifier"""
     if org.deleted:
         api.abort(410, "Organization has been deleted")
     EditOrganizationPermission(org).test()
     org.deleted = datetime.now()
     org.save()
     return "", 204
开发者ID:javanna2000,项目名称:udata,代码行数:8,代码来源:api.py

示例7: delete

 def delete(self, reuse):
     '''Delete a given reuse'''
     if reuse.deleted:
         api.abort(410, 'This reuse has been deleted')
     ReuseEditPermission(reuse).test()
     reuse.deleted = datetime.now()
     reuse.save()
     return '', 204
开发者ID:anukat2015,项目名称:udata,代码行数:8,代码来源:api.py

示例8: get

 def get(self, user):
     '''Get a user given its identifier'''
     if current_user.is_anonymous or not current_user.sysadmin:
         if not user.active:
             api.abort(410, 'User is not active')
         if user.deleted:
             api.abort(410, 'User has been deleted')
     return user
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:api.py

示例9: delete

 def delete(self, user):
     '''Delete a user given its identifier'''
     if user.deleted:
         api.abort(410, 'User has already been deleted')
     if user == current_user._get_current_object():
         api.abort(403, 'You cannot delete yourself with this API. ' +
                   'Use the "me" API instead.')
     user.mark_as_deleted()
     return '', 204
开发者ID:odtvince,项目名称:udata,代码行数:9,代码来源:api.py

示例10: post

 def post(self):
     '''Create a new scheduled job'''
     if 'crontab' in request.json and 'interval' in request.json:
         api.abort(400, 'Cannot define both interval and crontab schedule')
     if 'crontab' in request.json:
         form = api.validate(CrontabTaskForm)
     else:
         form = api.validate(IntervalTaskForm)
     return form.save(), 201
开发者ID:guillo-w,项目名称:udata,代码行数:9,代码来源:api.py

示例11: put

 def put(self, dataset):
     '''Update a dataset given its identifier'''
     request_deleted = request.json.get('deleted', True)
     if dataset.deleted and request_deleted is not None:
         api.abort(410, 'Dataset has been deleted')
     DatasetEditPermission(dataset).test()
     dataset.last_modified = datetime.now()
     form = api.validate(DatasetForm, dataset)
     return form.save()
开发者ID:opendatateam,项目名称:udata,代码行数:9,代码来源:api.py

示例12: delete

 def delete(self, org, badge_kind):
     '''Delete a badge for a given organization'''
     badge = None
     for badge in org.badges:
         if badge.kind == badge_kind:
             break
     if badge is None:
         api.abort(404, 'Badge does not exists')
     org.remove_badge(badge)
     return '', 204
开发者ID:grouan,项目名称:udata,代码行数:10,代码来源:api.py

示例13: remove

def remove(obj, kind):
    '''
    Handle badge removal API

    - Returns 404 if the badge for this kind is absent
    - Returns 204 on success
    '''
    if not obj.get_badge(kind):
        api.abort(404, 'Badge does not exists')
    obj.remove_badge(kind)
    return '', 204
开发者ID:anukat2015,项目名称:udata,代码行数:11,代码来源:api.py

示例14: handle_upload

 def handle_upload(self, dataset):
     prefix = '/'.join((dataset.slug,
                        datetime.now().strftime('%Y%m%d-%H%M%S')))
     infos = handle_upload(storages.resources, prefix)
     if 'html' in infos['mime']:
         api.abort(415, 'Incorrect file content type: HTML')
     infos['title'] = os.path.basename(infos['filename'])
     infos['checksum'] = Checksum(type='sha1', value=infos.pop('sha1'))
     infos['filesize'] = infos.pop('size')
     del infos['filename']
     return infos
开发者ID:opendatateam,项目名称:udata,代码行数:11,代码来源:api.py

示例15: post

 def post(self, reuse):
     '''Add a dataset to a given reuse'''
     if 'id' not in request.json:
         api.abort(400, 'Expect a dataset identifier')
     try:
         dataset = Dataset.objects.get_or_404(id=request.json['id'])
     except Dataset.DoesNotExist:
         api.abort(404, 'Dataset {0} does not exists'.format(request.json['id']))
     if dataset in reuse.datasets:
         return reuse
     reuse.datasets.append(dataset)
     reuse.save()
     return reuse, 201
开发者ID:anukat2015,项目名称:udata,代码行数:13,代码来源:api.py


注:本文中的udata.api.api.abort函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。