Commit 3fdc8a77 by Brian Zambrano

Fix "$query" KeyError in with PyMongo 2.2+

This appeared to be happening in the case where there were no PyMongo queries
and an empty dictionary was returned.  Using dict.get fixes this problem, and
is backwards compatible with PyMongo < 2.2.

Fixes #13
parent b7a96405
......@@ -43,7 +43,7 @@ def _get_stacktrace():
"Could not retrieve stack. IndexError exception occured in inspect.stack(). "
"This error might occur when jinja2 templates is on the stack.",
)]
return _tidy_stacktrace(reversed(stack))
else:
return []
......@@ -168,7 +168,7 @@ def _cursor_refresh(cursor_self):
# Normal Query
query_data['skip'] = privar('skip')
query_data['limit'] = privar('limit')
query_data['query'] = query_son['$query']
query_data['query'] = query_son.get('$query')
query_data['ordering'] = _get_ordering(query_son)
queries.append(query_data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment