bigboard r7436 - trunk/bigboard/stocks/twitter



Author: marinaz
Date: Tue Oct 28 06:08:45 2008
New Revision: 7436
URL: http://svn.gnome.org/viewvc/bigboard?rev=7436&view=rev

Log:
Try getting some other Twitter account when the current account is removed in case there is another one out there that is enabled.  


Modified:
   trunk/bigboard/stocks/twitter/TwitterStock.py

Modified: trunk/bigboard/stocks/twitter/TwitterStock.py
==============================================================================
--- trunk/bigboard/stocks/twitter/TwitterStock.py	(original)
+++ trunk/bigboard/stocks/twitter/TwitterStock.py	Tue Oct 28 06:08:45 2008
@@ -129,8 +129,7 @@
         self.__connections.add(self.__onlineaccounts_proxy, id)
 
     def _on_delisted(self):
-        if self.__twitter_account:
-            self.__on_account_removed(self.__twitter_account.GetObjectPath())
+        self.__remove_current_account()
         self.__connections.disconnect_all()
 
     def get_content(self, size):
@@ -150,8 +149,7 @@
        
         _logger.debug("in __on_account_added for %s %s" % (str(acct), acct.GetUsername()))    
   
-        if self.__twitter_account:
-            self.__on_account_removed(self.__twitter_account.GetObjectPath())
+        self.__remove_current_account()
        
         self.__twitter_account = acct
         self.__twitter_account_changed_signal_match = \
@@ -159,10 +157,9 @@
         self.__on_twitter_account_changed()  
     
     @log_except(_logger)
-    def __on_account_removed(self, acct_path):
-        _logger.debug("in __on_account_removed")
-        if self.__twitter_account and self.__twitter_account.GetObjectPath() == acct_path: 
-            _logger.debug("in __on_account_removed for %s", acct_path)   
+    def __remove_current_account(self):
+        if self.__twitter_account:
+            _logger.debug("in __remove_current_account for %s", self.__twitter_account.GetObjectPath())   
             self.__twitter_account_changed_signal_match.remove()
             self.__twitter_account_changed_signal_match = None 
             self.__twitter_account = None
@@ -171,6 +168,18 @@
             self.__box.append(self.__login_button)
 
     @log_except(_logger)
+    def __on_account_removed(self, acct_path):
+        _logger.debug("in __on_account_removed")
+        if self.__twitter_account and self.__twitter_account.GetObjectPath() == acct_path: 
+            self.__remove_current_account()
+            
+            # try getting some other Twitter account in case there is another one out there
+            # that is enabled  
+            all_twitter_account_paths = self.__onlineaccounts_proxy.GetEnabledAccountsWithTypes([TYPE_TWITTER])
+            for a_path in all_twitter_account_paths:
+                self.__on_account_added(a_path)
+
+    @log_except(_logger)
     def __on_twitter_account_changed(self):
         _logger.debug("will change stuff")
         username = self.__twitter_account.GetUsername()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]