本文整理汇总了Python中models.Place.get_by_key方法的典型用法代码示例。如果您正苦于以下问题:Python Place.get_by_key方法的具体用法?Python Place.get_by_key怎么用?Python Place.get_by_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Place
的用法示例。
在下文中一共展示了Place.get_by_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_get
# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import get_by_key [as 别名]
def place_get(place_id, place_key_str):
"""
It retrieves the place.
Parameters:
- place_id: the string id of the Place
- place_key_str: the urlsafe string representing the key.
Only one between place_id and place_key_str should be set, since they represent the same information,
but encoded in two different ways. They are both accepted for generality. If both are set, the id is used.
It returns a tuple:
- the requested place (or None in case of errors in the input),
- the status (a string indicating whether an error occurred),
- the http code indicating the type of error, if any
"""
try:
key = Place.make_key(place_id, place_key_str)
logging.info("KEY: " + str(key))
place = Place.get_by_key(key)
except TypeError as e:
logging.error("TypeError on Place.get_by_key: " + str(e))
return None, str(e), 400
return place, "OK", 200