From 5768f0e91c45449b00411b459c9a927861978d57 Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 20 May 2010 21:23:54 -0400 Subject: [PATCH] More fixes to the add_account function. Now we produce a 400 error on GetUserInfo --- hrafn.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/hrafn.py b/hrafn.py index 71ce623..9ffba34 100755 --- a/hrafn.py +++ b/hrafn.py @@ -67,7 +67,8 @@ class Hrafn(): # Now set up the accounts and their corresponding APIs self.accounts = {} for token in self.db['tokens']: - self.add_account(token) + api = apithreads.CustomApi(token) + self.add_account(api) if not self.db.has_key('active_user'): try: @@ -75,7 +76,6 @@ class Hrafn(): except IndexError: self.db['active_user'] = None - self.username = self.db['active_user'] try: @@ -83,7 +83,6 @@ class Hrafn(): except KeyError: self.api = None - if not self.db.has_key('open_tabs'): self.db['open_tabs'] = [] @@ -540,16 +539,16 @@ class Hrafn(): if token is None: return - # fixme: need this to work, but need username AFTER we create the API... - if not self.accounts.has_key(username): + api = apithreads.CustomApi(token) + + if not self.accounts.has_key(api.username): tokens = self.db['tokens'] tokens.append(token) self.db['tokens'] = tokens - self.add_account(token) + self.add_account(api) - def add_account(self, token): - api = apithreads.CustomApi(token) + def add_account(self, api): username = api.username self.accounts[username] = api self.accounts[username].sig_proxy.connect('lists-ready', self.on_lists_ready) @@ -564,14 +563,9 @@ class Hrafn(): if username == self.username: menu_item.set_active(True) - if first_item is None: - first_item = menu_item - - menu_item.connect('activate', self.on_account_changed, name) - self.accounts_menu.append(menu_item) - menu_item.show() - - + menu_item.connect('activate', self.on_account_changed, username) + self.accounts_menu.append(menu_item) + menu_item.show() ### end class Hrafn