diff options
author | Nathan Yergler <nathan@yergler.net> | 2012-11-26 20:24:30 -0800 |
---|---|---|
committer | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-12-10 12:30:04 +0100 |
commit | afe0afdb88727de854de48909e4eb28c1ff57c66 (patch) | |
tree | 7589a8cd4d41e11f2b3db46b73352ed1c260920f | |
parent | 41fc4698c5e6f41438c270bf088495bd2e7db3e2 (diff) | |
download | mediagoblin-afe0afdb88727de854de48909e4eb28c1ff57c66.tar.lz mediagoblin-afe0afdb88727de854de48909e4eb28c1ff57c66.tar.xz mediagoblin-afe0afdb88727de854de48909e4eb28c1ff57c66.zip |
Ensure query_dict is a dict after the contents have been modified.
_fix_query_dict modifies its argument in place. Ensure that the
argument passed in has a local name and will be passed into the
subsequent filter_by call.
-rw-r--r-- | mediagoblin/db/sql/base.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/mediagoblin/db/sql/base.py b/mediagoblin/db/sql/base.py index e10e7739..ca0c8166 100644 --- a/mediagoblin/db/sql/base.py +++ b/mediagoblin/db/sql/base.py @@ -51,12 +51,18 @@ class GMGTableBase(object): query = Session.query_property() @classmethod - def find(cls, query_dict={}): + def find(cls, query_dict=None): + if query_dict is None: + query_dict = {} + _fix_query_dict(query_dict) return cls.query.filter_by(**query_dict) @classmethod - def find_one(cls, query_dict={}): + def find_one(cls, query_dict=None): + if query_dict is None: + query_dict = {} + _fix_query_dict(query_dict) return cls.query.filter_by(**query_dict).first() |