diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2011-08-16 23:57:44 -0400 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2011-08-16 23:57:44 -0400 |
| commit | d0cb56932c251667420e4876f99f5fa6b5c8a9a6 (patch) | |
| tree | df902dbf255c1d6144b5f6f7992bf98ff92ff45c /requests/hooks.py | |
| parent | fc04d8a368b373945f2b7d701a683d1167ff4101 (diff) | |
| download | python-requests-d0cb56932c251667420e4876f99f5fa6b5c8a9a6.tar.gz | |
new hooks system
#118
Diffstat (limited to 'requests/hooks.py')
| -rw-r--r-- | requests/hooks.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/requests/hooks.py b/requests/hooks.py new file mode 100644 index 00000000..7e9f23a4 --- /dev/null +++ b/requests/hooks.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +requests.hooks +~~~~~~~~~~~~~~ + +This module provides the capabilities for the Requests hooks system. +""" + +import warnings + +def dispatch_hook(key, hooks, hook_data): + """""" + + hooks = hooks or dict() + + if key in hooks: + try: + return hooks.get(key).__call__(hook_data) or hook_data + + except Exception, why: + warnings.warn(str(why)) + + + return hook_data |
