Ejemplo n.º 1
0
 def do_get_entity(self, model, strid):
   """ Hook method to get data about an entity given model name and strid
   """
   entity = self.get_entity(model, strid)
   if entity is None:
     return {}
   return jsonutil.make_jobj(entity)
Ejemplo n.º 2
0
 def do_get_entity(self, model, strid):
     """ Hook method to get data about an entity given model name and strid
 """
     entity = self.get_entity(model, strid)
     if entity is None:
         return {}
     return jsonutil.make_jobj(entity)
Ejemplo n.º 3
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))

    coon = str(1 + int(self.get_cookie('coon', '0')))
    self.set_cookie('count', coon)
    self.set_cookie('ts', str(int(time.time())))
    failed, model, entity = self._get_model_and_entity(False, False, user)
    if failed: return
    if model is None:
      return self._serve(restutil.allModelClassNames())
    if entity is None:
      return self._serve([jsonutil.id_of(x) for x in model.all()])
    jobj = jsonutil.make_jobj(entity)
    return self._serve(jobj)