Introduce find_id_list
And code simplification in backends/browsers
This commit is contained in:
parent
cc1e587552
commit
080c4aff81
5 changed files with 27 additions and 60 deletions
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue