Exemple #1
0
 def proceedJson(self, data):
     result = {}
     if data[AccountManager.JSON_TYPE] == AccountManager.JSON_TYPE_CREATE_USER:
         user = Users()
         user.createNewUser(data[AccountManager.JSON_USER_NAME])
         result["user_id"] = user.key().id()
         result["user_name"] = user.user_name
         return result
Exemple #2
0
 def addNewComment(self, data):
     self._key = db.get(data[self.JSON_OBJECT_KEY])
     for name, value in data.items():
         if name == self.JSON_IMAGE:
             setattr(self, name, str(value))
         elif name == "user_id":
             userKey = db.Key.from_path("Users", int(value))
             if None == db.get(userKey):
                 logging.info("%s key user doesn't exist, will create a user automatically." % value)
                 user = Users(key=userKey)
                 user.createNewUser(data[self.JSON_MODEL])
             setattr(self, name, userKey)
         else:
             setattr(self, name, value)
     self.put()