--- a/dataimport.py Wed Mar 27 14:51:42 2013 +0100
+++ b/dataimport.py Wed Mar 27 14:53:06 2013 +0100
@@ -538,76 +538,6 @@
def nb_inserted_relations(self):
return len(self.relations)
- @deprecated("[3.7] index support will disappear")
- def build_index(self, name, type, func=None, can_be_empty=False):
- """build internal index for further search"""
- index = {}
- if func is None or not callable(func):
- func = lambda x: x['eid']
- for eid in self.types[type]:
- index.setdefault(func(self.eids[eid]), []).append(eid)
- if not can_be_empty:
- assert index, "new index '%s' cannot be empty" % name
- self.indexes[name] = index
-
- @deprecated("[3.7] index support will disappear")
- def build_rqlindex(self, name, type, key, rql, rql_params=False,
- func=None, can_be_empty=False):
- """build an index by rql query
-
- rql should return eid in first column
- ctl.store.build_index('index_name', 'users', 'login', 'Any U WHERE U is CWUser')
- """
- self.types[type] = []
- rset = self.rql(rql, rql_params or {})
- if not can_be_empty:
- assert rset, "new index type '%s' cannot be empty (0 record found)" % type
- for entity in rset.entities():
- getattr(entity, key) # autopopulate entity with key attribute
- self.eids[entity.eid] = dict(entity)
- if entity.eid not in self.types[type]:
- self.types[type].append(entity.eid)
-
- # Build index with specified key
- func = lambda x: x[key]
- self.build_index(name, type, func, can_be_empty=can_be_empty)
-
- @deprecated("[3.7] index support will disappear")
- def fetch(self, name, key, unique=False, decorator=None):
- """index fetcher method
-
- decorator is a callable method or an iterator of callable methods (usually a lambda function)
- decorator=lambda x: x[:1] (first value is returned)
- decorator=lambda x: x.lower (lowercased value is returned)
-
- decorator is handy when you want to improve index keys but without
- changing the original field
-
- Same check functions can be reused here.
- """
- eids = self.indexes[name].get(key, [])
- if decorator is not None:
- if not hasattr(decorator, '__iter__'):
- decorator = (decorator,)
- for f in decorator:
- eids = f(eids)
- if unique:
- assert len(eids) == 1, u'expected a single one value for key "%s" in index "%s". Got %i' % (key, name, len(eids))
- eids = eids[0]
- return eids
-
- @deprecated("[3.7] index support will disappear")
- def find(self, type, key, value):
- for idx in self.types[type]:
- item = self.items[idx]
- if item[key] == value:
- yield item
-
- @deprecated("[3.7] checkpoint() deprecated. use commit() instead")
- def checkpoint(self):
- self.commit()
-
-
class RQLObjectStore(ObjectStore):
"""ObjectStore that works with an actual RQL repository (production mode)"""
_rql = None # bw compat