[dataimport, migration] silence find_entities / find_one_entity warning
Deprecate associated methods to unify the API
--- a/dataimport.py Wed Apr 09 17:14:25 2014 +0200
+++ b/dataimport.py Wed Apr 09 17:26:57 2014 +0200
@@ -620,11 +620,13 @@
self.rql('SET X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
{'x': int(eid_from), 'y': int(eid_to)})
+ @deprecated("[3.19] use session.find(*args, **kwargs).entities() instead")
def find_entities(self, *args, **kwargs):
- return self.session.find_entities(*args, **kwargs)
+ return self.session.find(*args, **kwargs).entities()
+ @deprecated("[3.19] use session.find(*args, **kwargs).one() instead")
def find_one_entity(self, *args, **kwargs):
- return self.session.find_one_entity(*args, **kwargs)
+ return self.session.find(*args, **kwargs).one()
# the import controller ########################################################
--- a/server/migractions.py Wed Apr 09 17:14:25 2014 +0200
+++ b/server/migractions.py Wed Apr 09 17:26:57 2014 +0200
@@ -1342,17 +1342,23 @@
self.commit()
return entity
+ def cmd_find(self, etype, **kwargs):
+ """find entities of the given type and attribute values"""
+ return self.cnx.find(etype, **kwargs)
+
+ @deprecated("[3.19] use find(*args, **kwargs).entities() instead")
def cmd_find_entities(self, etype, **kwargs):
"""find entities of the given type and attribute values"""
- return self.cnx.find_entities(etype, **kwargs)
+ return self.cnx.find(etype, **kwargs).entities()
+ @deprecated("[3.19] use find(*args, **kwargs).one() instead")
def cmd_find_one_entity(self, etype, **kwargs):
"""find one entity of the given type and attribute values.
raise :exc:`cubicweb.req.FindEntityError` if can not return one and only
one entity.
"""
- return self.cnx.find_one_entity(etype, **kwargs)
+ return self.cnx.find(etype, **kwargs).one()
def cmd_update_etype_fti_weight(self, etype, weight):
if self.repo.system_source.dbdriver == 'postgres':
--- a/sobjects/cwxmlparser.py Wed Apr 09 17:14:25 2014 +0200
+++ b/sobjects/cwxmlparser.py Wed Apr 09 17:26:57 2014 +0200
@@ -467,7 +467,7 @@
self._clear_relation((ttype,))
def _find_entities(self, item, kwargs):
- return tuple(self._cw.find_entities(item['cwtype'], **kwargs))
+ return tuple(self._cw.find(item['cwtype'], **kwargs).entities())
class CWEntityXMLActionLinkInState(CWEntityXMLActionLink):