def locations_eateries_get(self,unused_request): status_code,couple_key = self.auth_api_user() if status_code == -2: raise endpoints.UnauthorizedException("Please sign in.") elif status_code == -1: return EateryLocation(status_code=-1) geocoded_hitlist_key = "GeocodedHitlist|" + str(couple_key.key().id()) # Get a list of Entity keys that are associated with this user and have been geocoded. geocoded_hitlist = ra_memcache.geocoded_hitlist_cache(geocoded_hitlist_key,couple_key) # List of response messages. items = [] for e in geocoded_hitlist: # Initialize the EateryMessage e_message = EateryLocation(restaurant_name=e.RestaurantName,latitude=e.Latitude,longitude=e.Longitude,geocoded=True,status_code=status_code) items.append(e_message) return EateryLocationCollection(items=items)
def eatery_geocode_insert(self,request): status_code,couple_key = self.auth_api_user() if status_code == -2: raise endpoints.UnauthorizedException("Please sign in.") elif status_code == -1: return EateryLocation(status_code=-1) key = 'Eatery|' + str(request.eatery_id) eatery = ra_memcache.cache_entity(key,request.eatery_id,couple_key,Eatery.by_id) if eatery: eatery.Latitude = request.latitude eatery.Longitude = request.longitude eatery.put() # Refresh memcache eatery = ra_memcache.cache_entity(key,request.eatery_id,couple_key,Eatery.by_id,update=True) geocoded_hitlist_key = "GeocodedHitlist|" + str(couple_key.key().id()) geocoded_hitlist = ra_memcache.geocoded_hitlist_cache(geocoded_hitlist_key,couple_key,update=True) else: return EateryLocation(status_code=-2) return EateryLocation(status_code=0)