Introduce find_id_list

And code simplification in backends/browsers
This commit is contained in:
Florent 2014-04-01 17:40:38 +02:00
commit 080c4aff81
5 changed files with 27 additions and 60 deletions

View file

@ -46,6 +46,16 @@ def empty(value):
return True
return False
def find_id_list(mylist, _id, error=None):
"""
Very simple tools to return an object with the matching _id
"""
for a in mylist:
if a.id == _id:
return a
if error is not None:
raise error()
return None
class UserError(Exception):
"""