本文整理汇总了Python中katapult.requests.RequestHelper.set_status方法的典型用法代码示例。如果您正苦于以下问题:Python RequestHelper.set_status方法的具体用法?Python RequestHelper.set_status怎么用?Python RequestHelper.set_status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类katapult.requests.RequestHelper
的用法示例。
在下文中一共展示了RequestHelper.set_status方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def put(self, source_name):
helper = RequestHelper(self)
source_name = urllib.unquote(source_name)
success, values = read_json_fields(helper, "url", "active", logger=logging)
if not success:
return
url, active = values
# a Feed must be sole owner of an ArtifactSource;
# fails if source already exists and is already linked to a feed
source = ArtifactSourceAccessor.get_by_name(source_name, return_none=True)
if source:
source_feed_key = Feed.get_by_source(source, keys_only=True, return_none=True)
if source_feed_key:
msg = "source '%s' is referenced by feed %s" % (source_name, source_feed_key.name())
helper.error(409, msg)
else:
source = ArtifactSourceAccessor.create(source_name)
# creates UrlResource if necessary
resource = UrlResourceAccessor.get_by_url(url, return_none=True)
if not resource:
resource = UrlResourceAccessor.create(url)
# create or update Feed
feed = Feed.get_by_source_name(source_name, return_none=True)
if feed:
feed.artifact_source = source
feed.url_resource = resource
feed.put()
else:
Feed.create(source_name, artifact_source=source, url=url, url_resource=resource, active=bool(active))
helper.set_status(204)
示例2: delete
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def delete(cls, rhandler, guid, **kw):
helper = RequestHelper(rhandler)
try:
ArtifactAccessor.delete(guid)
helper.set_status(204)
except NotFoundException, ex:
helper.error(404)
示例3: delete
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def delete(self, name, **kw):
helper = RequestHelper(self)
try:
ArtifactSourceAccessor.delete_by_name(name)
helper.set_status(204)
except NotFoundException, ex:
helper.error(404)
return
示例4: put
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def put(self, name, **kw):
helper = RequestHelper(self)
source = ArtifactSourceAccessor.get_by_name(name, return_none=True)
if source:
helper.set_status(409, "duplicate ArtifactSouce")
return
ArtifactSourceAccessor.create(name)
helper.set_status(204)
示例5: delete
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def delete(self, source_name):
helper = RequestHelper(self)
source_name = urllib.unquote(source_name)
feed = Feed.get_by_source_name(source_name, return_none=True)
if not feed:
helper.error(404)
return
feed.delete()
helper.set_status(204)
示例6: delete
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def delete(self):
helper = RequestHelper(self)
search_results = self.__search(helper)
if search_results:
keys = [u.key() for u in search_results]
db.delete(keys)
helper.write_json([k.name() for k in keys])
else:
helper.set_status(204)
示例7: delete
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def delete(self):
helper = RequestHelper(self)
memcache.flush_all()
helper.set_status(204)
示例8: args_call
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def args_call(*args, **kw):
handler = args[0]
helper = RequestHelper(handler)
helper.set_status(403)
示例9: delete
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def delete(self, key):
helper = RequestHelper(self)
ConfigurationAccessor.update(**{key: None})
helper.set_status(204)
示例10: delete
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def delete(self, username):
""" unfollows the specified user """
helper = RequestHelper(self)
t_api = TwitterConnector.new_api()
t_api.DestroyFriendship(username)
helper.set_status(204)
示例11: put
# 需要导入模块: from katapult.requests import RequestHelper [as 别名]
# 或者: from katapult.requests.RequestHelper import set_status [as 别名]
def put(self, username):
""" follows the specified user """
helper = RequestHelper(self)
t_api = TwitterConnector.new_api()
t_api.CreateFriendship(username)
helper.set_status(204)