Skip to content

Commit

Permalink
View API: Pop keys from kwargs before constructing the URL
Browse files Browse the repository at this point in the history
Thanks to akheron for spotting the previous non-working fix for the
problem.
  • Loading branch information
Jyrki Pulliainen committed Nov 19, 2010
1 parent f5b379e commit 2805e74
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions trombi/client.py
Expand Up @@ -334,13 +334,18 @@ def _really_callback(response):
else:
url = '_design/%s/_view/%s' % (design_doc, viewname)

# We need to pop keys before constructing the url to avoid it
# ending up twice in the request, both in the body and as a
# query parameter.
keys = kwargs.pop('keys', None)

if kwargs:
url = '%s?%s' % (url, _jsonize_params(kwargs))

if 'keys' in kwargs:
if keys is not None:
self._fetch(url, _really_callback,
method='POST',
body=json.dumps({'keys': kwargs.pop('keys')})
body=json.dumps({'keys': keys})
)
else:
self._fetch(url, _really_callback)
Expand Down

0 comments on commit 2805e74

Please sign in to comment.