From 3317efb6030a75737a11e0c8bc6393e6119d34f2 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Sat, 31 Oct 2009 14:19:04 -0500 Subject: [PATCH] Remove model validation. --- CHANGES | 1 + tweepy/api.py | 3 +-- tweepy/binder.py | 12 ------------ tweepy/models.py | 42 ------------------------------------------ 4 files changed, 2 insertions(+), 56 deletions(-) diff --git a/CHANGES b/CHANGES index 5a61a5b..82e51be 100644 --- a/CHANGES +++ b/CHANGES @@ -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] ===================== diff --git a/tweepy/api.py b/tweepy/api.py index 05633b2..07a3e6a 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -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 diff --git a/tweepy/binder.py b/tweepy/binder.py index ca13a1f..4da725c 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -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) diff --git a/tweepy/models.py b/tweepy/models.py index 127aac8..157271b 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -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) -- 2.25.1