def locationValidate(lat_lng): lat = lat_lng.split(',')[0].strip() lng = lat_lng.split(',')[1].strip() locationModel = Location() inlocation = locationModel.getLocationFromPosition({'lat':lat, 'lng':lng}) print inlocation # Now allowing posts from all location # if inlocation is None: # raise ValueError("This is an invalid location.") if inlocation is None: inlocation = dict() inlocation['id'] = 0 data = dict() data['lat_lng'] = lat_lng data['data'] = inlocation return data
def get(self): data = dict() args = parser.parse_args() try: deviceModel = Device() device = deviceModel.getDevice(args) lat_lng = args['lat_lng'] lat = lat_lng.split(',')[0].strip() lng = lat_lng.split(',')[1].strip() locationModel = Location() data['inlocation'] = locationModel.getLocationFromPosition({ 'lat': lat, 'lng': lng }) data['avllocation'] = locationModel.getAllLocations() return marshal( data, resource_fields), 404 if data['inlocation'] is None else 200 except Exception, e: data['message'] = str(e) return data, e.code if hasattr(e, 'code') else 500