openmedialibrary/oml/oxflask/utils.py

9 lines
200 B
Python
Raw Normal View History

2014-05-04 17:26:43 +00:00
def get_by_key(objects, key, value):
obj = filter(lambda o: o.get(key) == value, objects)
return obj and obj[0] or None
def get_by_id(objects, id):
return get_by_key(objects, 'id', id)