Commit 3317efb6 authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Remove model validation.

parent 912d3cf5
......@@ -6,6 +6,7 @@ during upgrade will be listed here.
+ API.verify_credentials() now returns an User object if credentials
are valid. Otherwise false will be returned.
+ API.new() removed
+ Removed model validation. Prone to breakage due to API changes.
1.1 -> 1.2 [Current]
=====================
......
......@@ -14,7 +14,7 @@ class API(object):
"""Twitter API"""
def __init__(self, auth_handler=None, host='twitter.com', cache=None,
secure=False, api_root='', validate=True,
secure=False, api_root='',
retry_count=0, retry_delay=0, retry_errors=None):
# you may access these freely
self.auth_handler = auth_handler
......@@ -22,7 +22,6 @@ class API(object):
self.api_root = api_root
self.cache = cache
self.secure = secure
self.validate = validate
self.retry_count = retry_count
self.retry_delay = retry_delay
self.retry_errors = retry_errors
......
......@@ -162,18 +162,6 @@ def bind_api(path, parser, allowed_param=[], method='GET', require_auth=False,
conn.close()
# validate result
if api.validate:
# list of results
if isinstance(out, list) and len(out) > 0:
if hasattr(out[0], 'validate'):
for result in out:
result.validate()
# single result
else:
if hasattr(out, 'validate'):
out.validate()
# store result in cache
if api.cache and method == 'GET':
api.cache.store(url, out)
......
......@@ -17,34 +17,9 @@ class Model(object):
pickle[k] = v
return pickle
@staticmethod
def _validate(model, attributes):
missing = []
for attr in attributes:
if not hasattr(model, attr):
missing.append(attr)
if len(missing) > 0:
raise TweepError('Missing required attribute(s) %s' % \
str(missing).strip('[]'))
def validate(self):
return
class Status(Model):
@staticmethod
def _validate(status):
Model._validate(status, [
'created_at', 'id', 'text', 'source', 'truncated', 'in_reply_to_status_id',
'in_reply_to_user_id', 'favorited', 'in_reply_to_screen_name'
])
if hasattr(status, 'user'):
User._validate(status.user)
def validate(self):
Status._validate(self)
def destroy(self):
return self._api.destroy_status(self.id)
......@@ -60,23 +35,6 @@ class Status(Model):
class User(Model):
@staticmethod
def _validate(user):
Model._validate(user, [
'id', 'name', 'screen_name', 'location', 'description', 'profile_image_url',
'url', 'protected', 'followers_count', 'profile_background_color',
'profile_text_color', 'profile_sidebar_fill_color',
'profile_sidebar_border_color', 'friends_count', 'created_at',
'favourites_count', 'utc_offset', 'time_zone',
'profile_background_image_url', 'statuses_count',
'notifications', 'following', 'verified'
])
if hasattr(user, 'status'):
Status._validate(user.status)
def validate(self):
User._validate(self)
def timeline(self, **kargs):
return self._api.user_timeline(**kargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment