def __init__(self, params, city_service, component=None): PositionDecorator.__init__(self, params, component) self.__city_service = city_service self._radius = utils.safe_cast(params.get(params_names.RADIUS, None), int, None) if self._radius is not None: if self._radius <= 0: self._radius = None
def get_paging_from_dict(args): to_int = lambda name: utils.safe_cast(args.get(name, None), int, None) to_none_if_neg_int = lambda v: v and (v > 0 and v or None) or None to_pos_int = lambda name: to_none_if_neg_int(to_int(name)) limit = to_pos_int(params_names.LIMIT) offset = to_pos_int(params_names.OFFSET) max_id = to_pos_int(params_names.MAX_ID) return limit, offset, max_id