[Cubicweb] Proposal: new method ResultSet.one()
Christophe de Vienne
cdevienne at gmail.com
Wed Dec 4 15:40:53 CET 2013
I propose to add a new method to ResultSet, named one(), that would
return exactly one entity from the resultset.
If more than one row and one column, or no row at all is found, an
exception would be raised.
It would allow to write :
entity = execute('SOME REQUEST').one()
where right now we have to do :
rset = execute('SOME REQUEST')
if rset.rowcount != 1:
# do something
entity = rset.get_entity(0, 0)
The idea is shamelessly borowed from SQLAlchemy Query.one() 
I have a patch that propose an implementation, I can push it for review
and discussion if you think it is worth it.
PS: btw, I did not manage to run the cubicweb test suite, is there some
things to be known to do so ?
More information about the Cubicweb