def post(self): body_json = json.loads(cgi.escape(self.request.body)) if 'email' not in body_json or 'reg_id' not in body_json: self.error(400) return email_addr = body_json['email'] gcm_reg_id = body_json['reg_id'] datastore.delete(email_addr, gcm_reg_id)
def api_delete(): token = request.args.get('token') if not token: return "Need valid google oauth token" url = request.args.get('url') if not url: return "need url parameter" return str(datastore.delete(token, url))
def add_quiz(username, quiz): # Add quiz to user data user_data = fetch_json('userData', filter={ "type": "username", "key": username }) print(quiz) print(quiz["id"]) print(user_data) # logging.info("quiz: {}".format(quiz)) # logging.info("quiz id: {}".format(quiz["id"])) # logging.info("user: {}".format(user_data)) user_data["quizIDs"].append(quiz["id"]) delete('userData', filter={"type": "username", "key": username}) store_json(user_data, "userData") # Store the new quiz store_json(quiz, "quizData")
d.create( "key1", b, 20 ) # arguments are ( Key , value(must be a json object) , timelimit in secs ) # In[3]: d.read("key1") # argument is key # In[4]: d.read("key1") #After the time limit overs # In[5]: d.delete("key1") #After the time limit overs # In[6]: d.create("key2", b, 15) # In[7]: d.delete("key2") # argument is key # In[8]: t1 = d.myThreadcreate( "key5", b, 0 ) #Multiple Threads for create option can be done by using this myThreadcreate class
#run the MODULE of MAIN FILE and import mainfile as a library import datastore as x #importing the main file("datastore" is the name of the file I have used) as a library x.create("sathyabama", 25) #to create a key with key_name,value given and with no time-to-live property x.create("rahul", 70, 3600) #to create a key with key_name,value given and with time-to-live property value given(number of seconds) x.read("sathyabama") #it returns the value of the respective key in Jasonobject format 'key_name:value' x.read("rahul") #it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR x.create("sathyabama", 50) #it returns an ERROR since the key_name already exists in the database x.delete("sathyabama") #it deletes the respective key and its value from the database(memory is also freed)
def remove(self): datastore.delete(self.__tablename__,where='%s=%s'%(self._primarykey,self.getval(self._primarykey)))
def remove(self): """Removes the current object from the datastore.""" where_key = {k:self.getval(k) for k in self._primarykeys} datastore.delete(self.__tablename__,where=web.db.sqlwhere(where_key))