def setGeocodeCache(self, REQUEST=None): """ Store a JSON representation of the Google Maps geocode cache """ cache = extractPostContent(REQUEST) try: cache = cache.decode('utf-8') except: pass self.geocache = cache return True
def setGeocodeCache(self, REQUEST=None): """ This method takes the geocodecache from the client and updates the methods on the locations with the latest latlong """ cache = extractPostContent(REQUEST) try: cache = cache.decode('utf-8') except: pass from json import loads geocode = loads(cache) for uid, geo in geocode.iteritems(): try: loc = self.unrestrictedTraverse(str(uid)) if loc.latlong != geo['latlong']: loc.latlong = geo['latlong'] except (KeyError, NotFound): # the location might have been removed or renamed # and the client still had the cache. continue