Exemple #1
0
  def get(self):
    user = users.get_current_user()
    result = {}
    
    if user == None:
      result['status'] = False
      result['message'] = 'User is not logged in'
    else:
      result['status'] = True
#      unique_id = user.federated_identity()
#      if unique_id is None:
#        unique_id = user.user_id()
      unique_id = str(user)

      data = memcache.get(unique_id)
      if data is None:
        passwords = StoredKey.all().filter('user = '******'passwords'] = []
        for password in passwords:
          result['passwords'].append(password.to_d())
        #memcache.set(unique_id, json.dumps(result['passwords']))
      else:
        result['passwords'] = json.loads(data)
  
    self.response.out.write(json.dumps(result))
    def post(self):
        user = users.get_current_user()
        result = {}
        result['status'] = True

        if user == None:
            result['status'] = False
            result['message'] = 'User is not logged in'
            self.response.out.write(json.dumps(result))
            return
        else:
            key = self.request.get('key')
            password = None

            if key != None and key != "":
                password = StoredKey.get(key)

            if password == None:
                password = StoredKey(username='******', password='******', title=' ')

            password.from_request(self.request)
            password.save()
            memcache.delete(str(user))

        self.response.out.write(json.dumps(result))
    def post(self):
        user = users.get_current_user()
        result = {}
        result["status"] = True

        if user == None:
            result["status"] = False
            result["message"] = "User is not logged in"
            self.response.out.write(json.dumps(result))
            return
        else:
            key = self.request.get("key")
            password = None

            if key != None and key != "":
                password = StoredKey.get(key)

            if password == None:
                password = StoredKey(username="******", password="******", title=" ")

            password.from_request(self.request)
            password.save()
            memcache.delete(str(user))

        self.response.out.write(json.dumps(result))
 def get(self):
   user = users.get_current_user()
   result = {}
   
   if user == None:
     result['status'] = False
     result['message'] = 'User is not logged in'
   else:
     key = self.request.get('key')
     if key != "" and key != None:
       password = StoredKey.get(key)
       if password == None:
         result['status'] = False
         result['message'] = 'Key could not retrieved from database'
       else:
         password.delete()
         result['status'] = True
     else:
       result['status'] = False
       result['message'] = 'Key was empty or not set'
     memcache.delete(str(user))
 
   self.response.out.write(json.dumps(result))
    def get(self):
        user = users.get_current_user()
        result = {}

        if user == None:
            result['status'] = False
            result['message'] = 'User is not logged in'
        else:
            key = self.request.get('key')
            if key != "" and key != None:
                password = StoredKey.get(key)
                if password == None:
                    result['status'] = False
                    result['message'] = 'Key could not retrieved from database'
                else:
                    password.delete()
                    result['status'] = True
            else:
                result['status'] = False
                result['message'] = 'Key was empty or not set'
            memcache.delete(str(user))

        self.response.out.write(json.dumps(result))