Remove model validation.
authorJosh Roesslein <jroesslein@gmail.com>
Sat, 31 Oct 2009 19:19:04 +0000 (14:19 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Sat, 31 Oct 2009 19:19:04 +0000 (14:19 -0500)
CHANGES
tweepy/api.py
tweepy/binder.py
tweepy/models.py

diff --git a/CHANGES b/CHANGES
index 5a61a5bd2e870484dad8f4e327f742dddd401ed7..82e51be166d579178ce5193d01ced94cff5ed0c6 100644 (file)
--- 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]
 =====================
index 05633b23ff273e28c1b8889c5eb03650c9ff53a6..07a3e6a8059335a8d6a73a43cb41abb2266ef607 100644 (file)
@@ -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
index ca13a1ff0204b7842c47f999ffaed365bc1ee940..4da725c8c7a67d86c4b6bc3fc615201ab8faeb53 100644 (file)
@@ -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)
index 127aac8907a2b87abe356aea05dfd85d05170662..157271bd47c059173929019c459464f797beac1e 100644 (file)
@@ -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)