From: Kenneth Reitz Date: Thu, 24 Feb 2011 06:50:38 +0000 (-0500) Subject: merge changes X-Git-Tag: v0.3.0^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7b8e9371a0ee9bb9bb8e2269474ca67088cdc86;p=services%2Fpython-requests.git merge changes --- diff --git a/requests/async.py b/requests/async.py index d0d66c2..88daa16 100644 --- a/requests/async.py +++ b/requests/async.py @@ -10,11 +10,13 @@ :license: ISC, see LICENSE for more details. """ + from __future__ import absolute_import import urllib import urllib2 from urllib2 import HTTPError + try: import eventlet eventlet.monkey_patch() @@ -28,16 +30,16 @@ if not 'eventlet' in locals(): except ImportError: pass + if not 'eventlet' in locals(): raise ImportError('No Async adaptations of urllib2 found!') + from .core import * -__all__ = ['Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete', 'auth_manager', 'AuthObject', - 'RequestException', 'AuthenticationError', 'URLRequired', 'InvalidMethod', 'HTTPError'] -__title__ = 'requests' -__version__ = '0.0.1' -__build__ = 0x000001 -__author__ = 'Dj Gilcrease' -__license__ = 'ISC' -__copyright__ = 'Copyright 2011 Kenneth Reitz' + +__all__ = [ + 'Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete', + 'auth_manager', 'AuthObject','RequestException', 'AuthenticationError', + 'URLRequired', 'InvalidMethod', 'HTTPError' +] diff --git a/requests/core.py b/requests/core.py index 922676a..3d7fcd7 100644 --- a/requests/core.py +++ b/requests/core.py @@ -18,15 +18,21 @@ from urllib2 import HTTPError from .packages.poster.encode import multipart_encode from .packages.poster.streaminghttp import register_openers -__all__ = ['Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete', 'auth_manager', 'AuthObject', - 'RequestException', 'AuthenticationError', 'URLRequired', 'InvalidMethod', 'HTTPError'] + __title__ = 'requests' __version__ = '0.2.5' __build__ = 0x000205 -__author__ = 'Kenneth Reitz, Dj Gilcrease' +__author__ = 'Kenneth Reitz' __license__ = 'ISC' __copyright__ = 'Copyright 2011 Kenneth Reitz' +__all__ = [ + 'Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete', + 'auth_manager', 'AuthObject','RequestException', 'AuthenticationError', + 'URLRequired', 'InvalidMethod', 'HTTPError' +] + + class _Request(urllib2.Request): """Hidden wrapper around the urllib2.Request object. Allows for manual setting of HTTP methods. @@ -199,6 +205,8 @@ class Response(object): if self.error: raise self.error + + class AuthManager(object): def __new__(cls): singleton = cls.__dict__.get('__singleton__') @@ -354,6 +362,7 @@ def request(method, url, **kwargs): return r.response + def get(url, params={}, headers={}, cookies=None, auth=None): """Sends a GET request. Returns :class:`Response` object. @@ -420,6 +429,8 @@ def delete(url, params={}, headers={}, cookies=None, auth=None): return request('DELETE', url, params=params, headers=headers, cookiejar=cookies, auth=auth) + + class RequestException(Exception): """There was an ambiguous exception that occured while handling your request."""