本文整理汇总了Python中datastore.DataStore.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python DataStore.fetch方法的具体用法?Python DataStore.fetch怎么用?Python DataStore.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datastore.DataStore
的用法示例。
在下文中一共展示了DataStore.fetch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tasks
# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import fetch [as 别名]
def get_tasks():
u = request.form['url'].lower()
url = Utilities.get_shortened_url(u)
url_3 = Utilities.get_shortened_url(u,3)
return_only_parent = False
# If url is same as parent url, return everything just for parent
# Dont redundantly return for parent and itself
if url == url_3 or url+'/' == url_3:
return_only_parent = True
ds = DataStore()
if not return_only_parent:
all_urls = Utilities.modify_url(url)
print all_urls
# If the same url is also a parent url, return all results of parent .
# And skip individual url results
for url in all_urls:
result = ds.fetch(url)
if result == False:
print " Tried for url " + url
else:
x = {"result":result}
return jsonify(x)
# If for our exact url and its modifications , nothing got returned
outer_url = "parent::" + Utilities.get_shortened_url(url,3)
print outer_url
result = ds.fetch_all_from_parent(outer_url)
if result :
x = {"result":result}
return jsonify(x)
else:
if outer_url[-1] == '/':
result = ds.fetch_all_from_parent(outer_url[:-1])
else:
result = ds.fetch_all_from_parent(outer_url + '/')
if result :
x = {"result":result}
return jsonify(x)
# If there is still nothing to show
return 'No Response'