Ejemplo n.º 1
0
 def defaultAction(self):
     self.response().clearHeaders()
     self.response()._headers["Content-Type"] = "application/json"
     num_queries = UrlHelper.getQueryNum(self.request().field("queries"))
     rp = partial(randint, 1, 10000)
     get = Database.DbSession.query(World).get
     worlds = [get(rp()).serialize() for _ in xrange(num_queries)]
     output = json.dumps(worlds)
     self.response()._headers["Content-Length"] = len(output)
     self.write(output)
Ejemplo n.º 2
0
 def defaultAction(self):
     self.response().clearHeaders()
     self.response()._headers["Content-Type"] = "application/json"
     num_queries = UrlHelper.getQueryNum(self.request().field("queries"))
     rp = partial(randint, 1, 10000)
     get = Database.DbSession.query(World).get
     worlds = [get(rp()).serialize() for _ in xrange(num_queries)]
     output = json.dumps(worlds)
     self.response()._headers["Content-Length"] = len(output)
     self.write(output)
Ejemplo n.º 3
0
 def defaultAction(self):
     self.response().clearHeaders()
     self.response()._headers["Content-Type"] = "application/json"
     num_queries = UrlHelper.getQueryNum(self.request().field("queries"))
     worlds = []
     rp = partial(randint, 1, 10000)
     ids = [rp() for _ in xrange(num_queries)]
     ids.sort()
     for id in ids:
         world = Database.DbSession.query(World).get(id)
         world.randomNumber = rp()
         worlds.append(world.serialize())
     Database.DbSession.commit()
     output = json.dumps(worlds)
     self.response()._headers["Content-Length"] = len(output)
     self.write(output)