convore.api will make the calls inside of objects.

This commit is contained in:
Kenneth Reitz
2011-02-19 11:40:28 -05:00
parent 01030981ef
commit 8343761c36
2 changed files with 42 additions and 2 deletions
+40
View File
@@ -0,0 +1,40 @@
import requests
import json
import models
API_URL = 'https://convore.com/api/'
def login(username, password):
auth = requests.AuthObject(username, password)
requests.add_autoauth(API_URL, auth)
class Groups(object):
def __init__(self):
pass
def __iter__(self):
r = requests.get(API_URL + 'groups.json')
groups = json.loads(r.content)['groups']
for group in groups:
_group = models.Group()
_group.import_from_api(group)
yield _group
def __getitem__(self, key):
r = requests.get(API_URL + 'groups/%s.json' % key)
group = models.Group()
_group = json.loads(r.content)['group']
group.import_from_api(_group)
return _group
def iterkeys():
return []
def iteritems():
return
+2 -2
View File
@@ -13,6 +13,7 @@ import json
import requests
import models
import api
__title__ = 'convore'
@@ -27,8 +28,7 @@ API_URL = 'https://convore.com/api/'
def login(username, password):
auth = requests.AuthObject(username, password)
requests.add_autoauth(API_URL, auth)
api.login(username, password)
def account_verify():