Exemplo n.º 1
0
 def create(self, key, val):
     key = str(key)
     _data = shelve.open('bokeh.server')
     if key in _data:
         raise DataIntegrityException("%s already exists" % key)
     _data[key] = json.dumps(val)
     _data.close()
Exemplo n.º 2
0
 def create(self, key, val):
     with self.redisconn.pipeline() as pipe:
         pipe.watch(key)
         pipe.multi()
         if self.redisconn.exists(key):
             raise DataIntegrityException("%s already exists" % key)
         pipe.set(key, json.dumps(val))
         pipe.execute()
Exemplo n.º 3
0
 def create(self, key, val):
     if key in self._data:
         raise DataIntegrityException("%s already exists" % key)
     self._data[key] = json.dumps(val)
Exemplo n.º 4
0
 def add_doc(self, docid, title):
     matching = [x for x in self.docs if x.get('title') == title]
     if len(matching) > 0:
         raise DataIntegrityException('title already exists')
     self.docs.append({'docid': docid, 'title': title})
Exemplo n.º 5
0
 def remove_doc(self, docid):
     matching = [x for x in self.docs if x.get('docid') == docid]
     if len(matching) == 0:
         raise DataIntegrityException('no document found')
     self.docs = [x for x in self.docs if x.get('docid') != docid]