From: Kenneth Reitz Date: Sun, 13 Feb 2011 21:16:36 +0000 (-0500) Subject: AuthAuths X-Git-Tag: v0.2.0~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b72e1d19aff997d00ef617a3aa0eea8ccdcc3984;p=services%2Fpython-requests.git AuthAuths --- diff --git a/requests/core.py b/requests/core.py index 876e701..81f8bc7 100644 --- a/requests/core.py +++ b/requests/core.py @@ -9,6 +9,7 @@ :copyright: (c) 2011 by Kenneth Reitz. :license: ISC, see LICENSE for more details. """ +import urllib import urllib2 @@ -20,16 +21,41 @@ __license__ = 'ISC' __copyright__ = 'Copyright 2011 Kenneth Reitz' +AUTHOAUTHS = [] + + class Request(object): """The :class:`Request` object. It's awesome. """ - pass + _METHODS = ('get', 'put', 'post', 'delete') + + def __init__(self): + self.headers = dict() + self.method = None + self.response = None + + def __setattr__(self, key, val): + if key == 'method': + if not val.lower() in _METHODS: + raise InvalidMethod() + + def send(self): + pass + set self.response() + # return True / False + class Response(object): """The :class:`Request` object. It's awesome. """ + def __init__(self): + self.content = None + self.status_code = None + self.headers = dict() + + class AuthObject(object): """The :class:`AuthObject` is a simple HTTP Authentication token. @@ -42,15 +68,27 @@ class AuthObject(object): self.password = password -def get(): +def get(url, params={}, headers={}, auth=None): pass -def post(): +def head(url, params={}, headers={}, auth=None): + pass + +def post(url, params={}, headers={}, auth=None): pass -def put(): +def put(url, data='', headers={}, auth=None): pass -def delete(): +def delete(url, params={}, headers={}, auth=None): pass + + +def add_autoauth(url, authobject): + global AUTHOAUTHS + + AUTHOAUTHS.append((url, authobject)) + +class InvalidMethod(Exception): + """An innappropriate method was attempted.""" \ No newline at end of file