本文整理汇总了Python中models.Location.toJSON方法的典型用法代码示例。如果您正苦于以下问题:Python Location.toJSON方法的具体用法?Python Location.toJSON怎么用?Python Location.toJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Location
的用法示例。
在下文中一共展示了Location.toJSON方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_location
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import toJSON [as 别名]
def add_location(request, loc_type, map_source ="google-maps", visibility = "private"):
location = Location(owner = users.get_current_user(),
map_source =map_source, loc_type = loc_type)
location.visibility = visibility
if loc_type == "extent":
location.name = request.get('loc-name')
location.latitude = float(request.get('latitude'))
location.longitude =float(request.get('longitude'))
location.zoom = int(request.get('zoom'))
elif loc_type == "point":
location.name = request.get('point-name')
location.latitude = float(request.get('latitude-point'))
location.longitude =float(request.get('longitude-point'))
location.zoom = int(request.get('zoom-point'))
tkn = location.buildToken()
location.token = tkn
location.put()
return location.toJSON()