Ejemplo n.º 1
0
 def get(self):
   cachedVal = memcache.get(models.genKeyForAllOrgsInfo())
   if cachedVal is not None:
     self.response.out.write(cachedVal)
   else:
     allOrgNames = []
     #with out an org table this really is not optimal
     for countryCode in geodata.countries.keys():
        allOrgNames.extend(map(lambda x: x.name,util.getOrgsInCountry(countryCode)))
     jsonDump = simplejson.dumps(util.getUnique(allOrgNames))
     memcache.set(models.genKeyForAllOrgsInfo(), jsonDump, 300)
     self.response.out.write(jsonDump)
Ejemplo n.º 2
0
  def get(self):
    self.response.headers.add_header('Cache-Control', 'no-cache, must-revalidate')
    self.response.headers.add_header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT')
    countryCode = self.request.get('countryCode')
    cachedVal = memcache.get(models.genKeyForOrgsInfo(countryCode))
    if cachedVal is not None:
      self.response.out.write(cachedVal)
    else:
      data  = {}
      results = util.getOrgsInCountry(countryCode)
      data['orgs'] = []
      for result in results:
        data['orgs'].append({"name": result.name, "center": [result.latlng.lat, result.latlng.lon], "freetext": result.freetext, "media": result.media, "icon": result.org_icon});

      newVal = simplejson.dumps(data)
      memcache.set(models.genKeyForOrgsInfo(countryCode), newVal, 10)
      self.response.out.write(newVal)