AuthAuths

This commit is contained in:
Kenneth Reitz
2011-02-13 16:16:36 -05:00
parent d8b19573f3
commit b72e1d19af
+43 -5
View File
@@ -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."""