Core w/ requests is MUCH simpler

This commit is contained in:
Kenneth Reitz
2011-02-14 02:59:34 -05:00
parent b44c2ad79f
commit 0d0fdbb12b
+17 -5
View File
@@ -9,6 +9,7 @@
:license: ISC, see LICENSE for more details.
"""
import requests
__title__ = 'convore'
@@ -20,6 +21,9 @@ __copyright__ = 'Copyright 2011 Kenneth Reitz'
API_URL = 'https://convore.com/api/'
class Convore(object):
"""The :class:`Convore` object is the heart of this api wrapper. It
provides all core functionality.
@@ -30,13 +34,21 @@ class Convore(object):
"""
def __init__(self, username, password):
self.username = username
self.password = password
requests.add_autoauth(API_URL, requests.AuthObject(self.username, self.password))
self.verify()
def verify(self):
"""Authenticates. Returns True if authentication is successful, False if not."""
pass
class AuthorizationFailed(Exception):
"Your given username/password was denied access."
r = requests.get(API_URL + 'account/verify.json')
if r.status_code == 200:
return True
else:
return False