basics for editable datapoints

This commit is contained in:
Kenneth Reitz
2011-07-23 23:06:26 -04:00
parent 388e2524f1
commit f0441843c6
+31 -3
View File
@@ -16,6 +16,7 @@ class BaseResource(object):
_dates = [] _dates = []
_bools = [] _bools = []
_map = {} _map = {}
_writeable = []
def __init__(self): def __init__(self):
@@ -53,21 +54,48 @@ class BaseResource(object):
_gh = gh _gh = gh
) )
def update(self):
pass
def setattr(self, k, v):
# TODO: when writable key changed,
pass
class User(BaseResource): class User(BaseResource):
"""Github User object model.""" """Github User object model."""
_strings = ['login', 'gravatar_url', 'url', 'name', 'company', _strings = [
'blog', 'location', 'email', 'bio', 'html_url'] 'login','gravatar_url', 'url', 'name', 'company', 'blog', 'location',
'email', 'bio', 'html_url']
_ints = ['id', 'public_repos', 'public_gists', 'followers', 'following'] _ints = ['id', 'public_repos', 'public_gists', 'followers', 'following']
_datetimes = ['created_at',] _datetimes = ['created_at',]
_booleans = ['hireable', ] _booleans = ['hireable', ]
_map = {} _map = {}
_writeable = ['name', 'email', 'blog', 'company', 'location', 'hireable', 'bio']
def __init__(self): def __init__(self):
super(User, self).__init__() super(User, self).__init__()
def __repr__(self): def __repr__(self):
return '<user {0}>'.format(self.login) return '<user {0}>'.format(self.login)
def _update(self):
"""Update the authenticated user."""
# TODO: check that user is authenticated
args = to_api(
dict(
favorite=self.favorite,
archive=self.archive,
read_percent=self.read_percent,
),
int_keys=('favorite', 'archive')
)
r = self._rdd._post_resource(('bookmarks', self.id), **args)
return r