Exemple #1
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/plain'
     self.response.out.write('Apagando pontos...')
     while Ponto.all().fetch(1):
         db.delete(Ponto.all().fetch(100))
     self.response.out.write('Apagando linhas...')
     while Linha.all().fetch(1):
         db.delete(Linha.all().fetch(100))
     self.response.out.write('Ok')
Exemple #2
0
 def get(self):
     key = self.request.get("key")
     client = memcache.Client()
     chave_memcache = "linha_json_" + key
     linha_obj = client.get(chave_memcache)
     if linha_obj is None:
         linha = Linha.get(db.Key(key))
         linha_obj = {
                       "key" : str(linha.key()),
                       "nome" : linha.nome,
                       "url" : linha.url,
                       "hashes" : linha.hashes()}
         client.add(chave_memcache, linha_obj)
         self.response.out.write("gerou cache de %s " % chave_memcache)
     else:
         self.response.out.write("ja tinha cache de %s " % chave_memcache)
     chave_memcache = "pontos_json_" + key;
     pontos_json = client.get(chave_memcache)
     if pontos_json is None:
         linha = Linha.get(db.Key(key))
         pontos = Ponto.all().filter("linha = ", linha).order("ordem")
         pontos_json = simplejson.dumps([(ponto.lat, ponto.lng) for ponto in pontos])
         client.add(chave_memcache, pontos_json)
         self.response.out.write("gerou cache de %s " % chave_memcache)
     else:
         self.response.out.write("ja tinha cache de %s " % chave_memcache)
 def HandleEntity(self, entity):
     linha = Linha.all().filter("nome =", entity["nome"]).fetch(1)[0]
     ponto = Ponto(ordem=entity["ordem"], linha=linha, lat=entity["lat"], lng=entity["lng"])
     pontosAnt = Ponto.all().filter("linha =", linha).filter("ordem =", ponto.ordem - 1).fetch(1)
     if pontosAnt:
         pontoAnt = pontosAnt[0]
         ponto.setNearhash(pontoAnt)
     ponto.put()
     return None
Exemple #4
0
 def get(self):
     self.response.headers['Content-Type'] = 'application/json'
     key = self.request.get("key")
     chave_memcache = "pontos_json_" + key;
     client = memcache.Client()
     pontos_json = client.get(chave_memcache)
     if pontos_json is None:
         linha = Linha.get(db.Key(key))
         pontos = Ponto.all().filter("linha = ", linha).order("ordem")
         pontos_json = simplejson.dumps([(ponto.lat, ponto.lng) for ponto in pontos])
         client.add(chave_memcache, pontos_json)
     callback = self.request.get("callback");
     if callback:
         pontos_json = callback + "(" + pontos_json + ");"            
     self.response.out.write(pontos_json)