Fix a bug in the cache code which would error when loading non-Model objects.
authorJosh Roesslein <jroesslein@gmail.com>
Sun, 17 Oct 2010 02:58:56 +0000 (21:58 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Sun, 17 Oct 2010 02:58:56 +0000 (21:58 -0500)
tweepy/binder.py

index 731ab6234284e55507ce6767ef76af1fd9c05a8b..bf2dec35fd3a06d3a85ccf59f371072c050298a4 100644 (file)
@@ -9,6 +9,7 @@ import re
 
 from tweepy.error import TweepError
 from tweepy.utils import convert_to_utf8_str
+from tweepy.models import Model
 
 re_path_template = re.compile('{\w+}')
 
@@ -114,9 +115,11 @@ def bind_api(**config):
                     # must restore api reference
                     if isinstance(cache_result, list):
                         for result in cache_result:
-                            result._api = self.api
+                            if isinstance(result, Model):
+                                result._api = self.api
                     else:
-                        cache_result._api = self.api
+                        if isinstance(cache_result, Model):
+                            cache_result._api = self.api
                     return cache_result
 
             # Continue attempting request until successful