Skip to content

Commit

Permalink
add a flex point for APIs that need something other than POST-style b…
Browse files Browse the repository at this point in the history
…odies
  • Loading branch information
tswicegood committed Feb 3, 2010
1 parent 089da6f commit c479a83
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dolt/__init__.py
Expand Up @@ -19,14 +19,15 @@ def __init__(self, http=None):
def __call__(self, *args, **kwargs):
self._attribute_stack += [str(a) for a in args]
self._params = kwargs
body = None
if self._method == 'POST':
body = (self._params_template % urllib.urlencode(self._params))[1:]

body = self._generate_body()
response, data = self._http.request(self.get_url(), self._method, body=body)
self._attribute_stack = []
return self._handle_response(response, data)

def _generate_body(self):
if self._method == 'POST':
return (self._params_template % urllib.urlencode(self._params))[1:]

def _handle_response(self, response, data):
return simplejson.loads(data)

Expand Down

0 comments on commit c479a83

Please sign in to comment.