def make_coll(self, use_indices): with self.store.begin(write=True): self.coll = self.store.add_collection('stuff', encoder=self.ENCODER, key_func=self.KEY_FUNC) if use_indices: acid.add_index(self.coll, 'rev_name', lambda p: p['name']) acid.add_index(self.coll, 'rev_locn', lambda p: p['location'])
def test1(self): store = acid.open('list:/') with store.begin(write=True): stuff = store.add_collection('stuff') acid.add_index(stuff, 'foop', lambda rec: 'foop') key = stuff.put(u'temp') assert store['foop'].find('foop') == 'temp' assert stuff.get(1) == 'temp' stuff.delete(1) assert stuff.get(1) is None i = store['foop'].find('foop') assert i is None, i
def create_collection(cls): if not hasattr(cls, 'META_STORE'): raise TypeError('%s nor any of its bases have been bound to a ' 'Store. You must call %s.bind_store() with a ' 'acid.Store instance.' % (cls.__name__, cls.__name__)) key_func = getattr(cls, 'META_KEY_FUNC', None) coll = cls.META_STORE.add_collection(name=cls.META_COLLECTION_NAME, key_func=key_func, encoder=cls.META_ENCODER) for index_func in cls.META_INDEX_FUNCS: acid.add_index(coll, index_func.func_name, index_func) cls.META_COLLECTION = coll
def create_collection(cls): if not hasattr(cls, 'META_STORE'): raise TypeError('%s nor any of its bases have been bound to a ' 'Store. You must call %s.bind_store() with a ' 'acid.Store instance.' % (cls.__name__, cls.__name__)) key_func = getattr(cls, 'META_KEY_FUNC', None) coll = cls.META_STORE.add_collection( name=cls.META_COLLECTION_NAME, key_func=key_func, encoder=cls.META_ENCODER) for index_func in cls.META_INDEX_FUNCS: acid.add_index(coll, index_func.func_name, index_func) cls.META_COLLECTION = coll
def setUp(self): self.store = acid.open('list:/') self.e = self.store.engine self.t = self.store.begin() self.t.__enter__() self.coll = self.store.add_collection('stuff') self.i = acid.add_index(self.coll, 'idx', lambda obj: (69, obj)) self.key = self.coll.put(u'dave') self.key2 = self.coll.put(u'dave2') self.expect = [(69, u'dave'), self.key] self.expect2 = [(69, u'dave2'), self.key2] self.first = [self.expect] self.second = [self.expect2] self.both = [self.expect, self.expect2] # Insert junk in a higher collection to test iter stop conds. self.coll2 = self.store.add_collection('stuff2') self.i2 = acid.add_index(self.coll2, 'idx', lambda obj: (69, obj)) self.coll2.put(u'XXXX') self.coll2.put(u'YYYY')