Mercurial > pylearn
changeset 619:fa6585609e01
added api0.filter_eq_dct
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Sat, 17 Jan 2009 21:20:32 -0500 |
parents | 8aef46b42cb5 |
children | 04752b23da8d |
files | pylearn/dbdict/api0.py pylearn/dbdict/sql.py |
diffstat | 2 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dbdict/api0.py Sat Jan 17 19:13:17 2009 -0500 +++ b/pylearn/dbdict/api0.py Sat Jan 17 21:20:32 2009 -0500 @@ -307,6 +307,12 @@ return h_self._Query(q) + def filter_eq_dct(q_self, dct): + rval = q_self + for key, val in dct.items(): + rval = rval.filter_eq(key,val) + return rval + def all(q_self): """Return an iterator over all matching dictionaries.
--- a/pylearn/dbdict/sql.py Sat Jan 17 19:13:17 2009 -0500 +++ b/pylearn/dbdict/sql.py Sat Jan 17 21:20:32 2009 -0500 @@ -211,7 +211,7 @@ """ job = copy.copy(jobdict) - do_insert = force_dup or (None is db.query(**job).first()) + do_insert = force_dup or (None is db.query.filter_eq_dct(job).first()) if do_insert: job[STATUS] = START job[PRIORITY] = 1.0