Achieve full API compatibility.
authorDouglas Morrison <skyfire@xynta.ch>
Wed, 12 Oct 2011 13:21:09 +0000 (13:21 +0000)
committerDouglas Morrison <skyfire@xynta.ch>
Wed, 12 Oct 2011 13:21:09 +0000 (13:21 +0000)
requests/api.py
requests/hooks.py

index 0417f81df3ebfbb21565fd8dc473a3fc2ec434ef..dea4c1adc833a2e46dce4a7cd287250cda1b147a 100644 (file)
@@ -14,7 +14,7 @@ This module implements the Requests API.
 from ._config import get_config
 from .models import Request, Response
 from .status_codes import codes
-from .hooks import dispatch_hooks
+from .hooks import dispatch_hook
 from .utils import cookiejar_from_dict, header_expand
 
 
@@ -73,13 +73,13 @@ def request(method, url,
     )
 
     # Arguments manipulation hook.
-    args = dispatch_hooks('args', hooks, args)
+    args = dispatch_hook('args', hooks, args)
 
     # Create Request object.
     r = Request(**args)
 
     # Pre-request hook.
-    r = dispatch_hooks('pre_request', hooks, r)
+    r = dispatch_hook('pre_request', hooks, r)
 
     # Only construct the request (for async)
     if _return_request:
@@ -90,10 +90,10 @@ def request(method, url,
 
     # TODO: Add these hooks inline.
     # Post-request hook.
-    r = dispatch_hooks('post_request', hooks, r)
+    r = dispatch_hook('post_request', hooks, r)
 
     # Response manipulation hook.
-    r.response = dispatch_hooks('response', hooks, r.response)
+    r.response = dispatch_hook('response', hooks, r.response)
 
     return r.response
 
index cd113b97d11e10ab46d4e204fcfcdf00d02487b2..36ec3c0674e7ba003c999abcab6449d99aaa6be9 100644 (file)
@@ -26,7 +26,7 @@ import warnings
 import collections
 
 
-def dispatch_hooks(key, hooks, hook_data):
+def dispatch_hook(key, hooks, hook_data):
     """Dipatches a hook dictionary on a given peice of data."""
 
     hooks = (hooks or {}).get(key, [])