Merge pull request #646 from mkomitee/hooks

Allowing hooks to return responses that indicate errors
This commit is contained in:
Kenneth Reitz
2012-06-04 07:44:56 -07:00
+4 -2
View File
@@ -30,7 +30,6 @@ import traceback
HOOKS = ('args', 'pre_request', 'pre_send', 'post_request', 'response')
def dispatch_hook(key, hooks, hook_data):
"""Dispatches a hook dictionary on a given piece of data."""
@@ -44,7 +43,10 @@ def dispatch_hook(key, hooks, hook_data):
for hook in hooks:
try:
hook_data = hook(hook_data) or hook_data
_hook_data = hook(hook_data)
if _hook_data is not None:
hook_data = _hook_data
except Exception:
traceback.print_exc()