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


Python DataStore.fetch方法代码示例

本文整理汇总了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'
开发者ID:shahharsh2603,项目名称:twitter-coupon-crawler,代码行数:53,代码来源:webservice.py


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