Exemplo n.º 1
0
 def _serve(self, data):
   counter = self.get_cookie('counter')
   if counter:
     self.set_cookie('counter', str(int(counter) + 1))
   else:
     self.set_cookie('counter', '0')
   return jsonutil.send_json(self.response, data)
Exemplo n.º 2
0
  def get(self):
    """ Get JSON data for model names, entity IDs of a model, or an entity.

    Depending on the request path, serve as JSON to the response object:
    - for a path of /classname/id, a jobj for that entity
    - for a path of /classname, a list of id-only jobjs for that model
    - for a path of /, a list of all model classnames
    """
    user = users.get_current_user()
    if user is None:
      return self.redirect(users.create_login_url(self.request.uri))
    logger.info("getting latest for user %s" % user)
    q = models.Sample.all().filter("user ="******"-created")
    results = q.fetch(1)
    if len(results):
      return jsonutil.send_json(self.response, {'created':results[0].created})
    else:
      return jsonutil.send_json(self.response, {})
Exemplo n.º 3
0
 def _serve(self, data):
   """ Serves a result in JSON, and hooks-down from the handler """
   try: return jsonutil.send_json(self.handler.response, data)
   finally: self.hookdown()
Exemplo n.º 4
0
 def _serve(self, data):
     """ Serves a result in JSON, and hooks-down from the handler """
     try:
         return jsonutil.send_json(self.handler.response, data)
     finally:
         self.hookdown()