本文整理汇总了Python中models.Place.store方法的典型用法代码示例。如果您正苦于以下问题:Python Place.store方法的具体用法?Python Place.store怎么用?Python Place.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Place
的用法示例。
在下文中一共展示了Place.store方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_create
# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import store [as 别名]
def place_create(place):
"""
It stores a new place.
Parameters:
- place: the Place containing the new information to store.
It returns a tuple:
- the created 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:
res = Place.store(place, None)
except (TypeError, ValueError, InvalidKeyException) as e:
return None, str(e), 400
return res, "OK", 200
示例2: place_update
# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import store [as 别名]
def place_update(in_place, place_id, place_key_str):
"""
It updates the place.
Parameters:
- in_place: the Place containing the information to update
- 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 place with updated information (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:
res = Place.store(
in_place, Place.make_key(place_id, place_key_str))
except (TypeError, ValueError, InvalidKeyException) as e:
return None, str(e), 400
return res, "OK", 200