本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_region方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_region方法的具体用法?Python QueryHelper.get_region怎么用?Python QueryHelper.get_region使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.queryhelper.QueryHelper
的用法示例。
在下文中一共展示了QueryHelper.get_region方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_region [as 别名]
def get(self):
"""Get the detail of a region.
"""
status = ErrorCode.SUCCESS
try:
rid = self.get_argument('rid')
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
logging.exception("[UWEB] cid: %s get report region data format illegal. Exception: %s",
self.current_user.cid, e.args)
self.write_ret(status)
return
try:
region = QueryHelper.get_region(rid, self.db)
if not region:
status = ErrorCode.REGION_NOT_EXISTED
self.write_ret(status)
return
if region.region_shape == UWEB.REGION_SHAPE.CIRCLE:
res = DotDict(region_id=region.region_id,
region_name=region.region_name,
region_shape=region.region_shape,
circle=DotDict(latitude=region.latitude,
longitude=region.longitude,
radius=region.radius),
)
elif region.region_shape == UWEB.REGION_SHAPE.POLYGON:
polygon = []
points = region.points
point_lst = points.split(':')
for point in point_lst:
latlon = point.split(',')
dct = {'latitude':latlon[0],
'longitude':latlon[1]}
polygon.append(dct)
res = DotDict(region_id=region.region_id,
region_name=region.region_name,
region_shape=region.region_shape,
polygon=polygon)
self.write_ret(status,
dict_=DotDict(res=res))
except Exception as e:
logging.exception("[UWEB] cid: %s get report region failed. Exception: %s",
self.current_user.cid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)