本文整理汇总了Python中models.Place.get_list方法的典型用法代码示例。如果您正苦于以下问题:Python Place.get_list方法的具体用法?Python Place.get_list怎么用?Python Place.get_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Place
的用法示例。
在下文中一共展示了Place.get_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_list_get
# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import get_list [as 别名]
def place_list_get(filters, user_id):
"""
It retrieves a list of places corresponding to the specified filters.
Parameters:
- filters: a dictionary containing the characteristics the returned places should have.
- user_id: if it s set, the personal data about the user added to each place (like ratings)
Available filters:
- 'city': 'city!province!state!country'
The 'city' filter contains the full description of the city, with values separated with a '!'.
This string is split and used to retrieve only the places that are in the specified city.
'null' is used if part of the full city description is not available [example: 'Trento!TN!null!Italy'
or if a bigger reagion is considered [example: 'null!TN!null!Italy' retrieves all places in the province of Trento]
- 'lat', 'lon' and 'max_dist': lat and lon indicates the user position, while max_dist is a measure expressed in meters
and represnt the radius of the circular region the user is interested in.
Returns a tuple:
- list of Places that satisfy the filters
- status message
- the http code indicating the type of error, if any
"""
try:
res = Place.get_list(filters, user_id)
except (TypeError, ValueError) as e:
return None, str(e), 400
return res, "OK", 200