Пример #1
0
 def del_item(self, userid, item):
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     num_deleted = self._del_items(userid, [item], version, data, casid)
     if num_deleted == 0:
         raise ItemNotFoundError
     return version
Пример #2
0
 def del_item(self, userid, item):
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     num_deleted = self._del_items(userid, [item], version, data, casid)
     if num_deleted == 0:
         raise ItemNotFoundError
     return version
Пример #3
0
 def __init__(self, storage):
     self.storage = storage
     self.connection = storage.dbconnector.connect()
     self.new_version = get_new_version()
     self.timestamp = time.time()
     self.cache = defaultdict(SQLCachedCollectionData)
     self.locked_collections = set()
     self._nesting_level = 0
Пример #4
0
 def __init__(self, storage):
     self.storage = storage
     self.connection = storage.dbconnector.connect()
     self.new_version = get_new_version()
     self.timestamp = time.time()
     self.cache = defaultdict(SQLCachedCollectionData)
     self.locked_collections = set()
     self._nesting_level = 0
Пример #5
0
 def set_item(self, userid, item, bso):
     bso["id"] = item
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     num_created = self._set_items(userid, [bso], version, data, casid)
     return {
         "created": num_created == 1,
         "version": version,
     }
Пример #6
0
 def set_item(self, userid, item, bso):
     bso["id"] = item
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     num_created = self._set_items(userid, [bso], version, data, casid)
     return {
         "created": num_created == 1,
         "version": version,
     }
Пример #7
0
 def del_items(self, userid, items):
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     self._del_items(userid, items, version, data, casid)
     return data["version"]
Пример #8
0
 def del_collection(self, userid):
     if not self.cache.delete(self.get_key(userid)):
         raise CollectionNotFoundError
     return get_new_version()
Пример #9
0
 def set_items(self, userid, items):
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     self._set_items(userid, items, version, data, casid)
     return version
Пример #10
0
 def del_items(self, userid, items):
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     self._del_items(userid, items, version, data, casid)
     return data["version"]
Пример #11
0
 def del_collection(self, userid):
     if not self.cache.delete(self.get_key(userid)):
         raise CollectionNotFoundError
     return get_new_version()
Пример #12
0
 def set_items(self, userid, items):
     version = get_new_version()
     data, casid = self.get_cached_data(userid)
     self._set_items(userid, items, version, data, casid)
     return version