Example #1
0
 def execute(self, key, action, args):
     rows = self.get_rows(key)
     if len(rows) == 0:
         row = Row(key)
         t = self.transaction()
         t.add( row.statement(action, args) )
         self.commit_transaction(t)
     elif len(rows) == 1:
         row = rows[0]
         t = self.transaction()
         t.add( row.statement(action, args) )
         self.commit_transaction(t)
     else:
         raise Exception("too many docs!!!")                   
Example #2
0
 def test_put(self):
     self.init()
     x = self.connect()
     t = x.transaction()
     r = Row('test')
     t.add( r.statement('update', {'one':1}) )
     x.commit_transaction(t)
 
     rows = x.get_rows('test')
     
     self.assertEqual([i.data for i in rows], [{'one':1}])
Example #3
0
 def test_many_keys_single_transaction(self):
     bunch_o_keys = [(i, gen()) for i in range(20)]
     
     self.init()
     x = self.connect()
 
     value = {}
     
     t = x.transaction()
     
     for index, i in bunch_o_keys:
         r = Row('test')
         t.add( r.statement('update', {i:index}) )
         value.update({i:index})
 
     x.commit_transaction(t)
 
     data = x.get_rows('test')
     data = data[0].data
     
     self.assertEqual(data, value)
Example #4
0
 def create(self, key, value):
     row = Row(key)
     t = self.transaction()
     t.add( row.statement('set', value) )
     self.commit_transaction(t)