def POST(self, key): """POST called to create a new node.""" user = users.get_current_user() node_data = json.dec(web.data()) assert not key assert not node_data.get("key") logging.info("New Node: %r" % node_data) new_node = models.Node.new_for_user(user, node_data) new_node.put() return json.enc(new_node)
def PUT(self, key): """PUT called to save an existing node.""" user = users.get_current_user() # TODO: handle errors? new_node = json.dec(web.data()) # Check old node belongs to this user old_node = models.Node.get(new_node.key()) assert old_node.user == user new_node.put() # Remove reference to children since these should be transient # and sending them back after a save request confuses the # client and causes duplicate child nodes. new_node.children = None return json.enc(new_node)