Made current account persistent across sessions
This commit is contained in:
parent
2b3406378a
commit
3a4e32f0b3
28
mytwitter.py
28
mytwitter.py
|
@ -52,6 +52,17 @@ class MyTwitter():
|
|||
# the lists-ready signal
|
||||
self.init_user_interface('./default.glade')
|
||||
|
||||
# And init the DB stuff here
|
||||
db_file = os.path.expanduser(config.get('global', 'dbfile'))
|
||||
self.db = shelve.open(db_file)
|
||||
|
||||
if not self.db.has_key('active_page'):
|
||||
self.db['active_page'] = 0
|
||||
|
||||
self.num_entries = int(config.get('global', 'entries'))
|
||||
self.refresh_time = int(config.get('global', 'refreshtime'))
|
||||
|
||||
# Now set up the accounts and their corresponding APIs
|
||||
self.accounts = {}
|
||||
for item in config.sections():
|
||||
if (re.match(r'account', item)):
|
||||
|
@ -59,18 +70,12 @@ class MyTwitter():
|
|||
self.accounts[username] = apithreads.CustomApi(username=username, password=config.get(item, 'password'))
|
||||
self.accounts[username].sig_proxy.connect('lists-ready', self.on_lists_ready)
|
||||
|
||||
self.username = self.accounts.keys()[0]
|
||||
if not self.db.has_key('active_user'):
|
||||
self.db['active_user'] = self.accounts.keys()[0]
|
||||
|
||||
self.username = self.db['active_user']
|
||||
self.api = self.accounts[self.username]
|
||||
|
||||
self.num_entries = int(config.get('global', 'entries'))
|
||||
self.refresh_time = int(config.get('global', 'refreshtime'))
|
||||
|
||||
db_file = os.path.expanduser(config.get('global', 'dbfile'))
|
||||
self.db = shelve.open(db_file)
|
||||
|
||||
if not self.db.has_key('active_page'):
|
||||
self.db['active_page'] = 0
|
||||
|
||||
if not self.db.has_key('open_tabs'):
|
||||
self.db['open_tabs'] = [(self.username + '/Home', None, False), ('@' + self.username, None, False), (self.username + '/Direct Messages', None, False)]
|
||||
|
||||
|
@ -498,10 +503,11 @@ class MyTwitter():
|
|||
|
||||
|
||||
def on_account_changed(self, widget, new_account):
|
||||
print 'debug: on_account_changed()'
|
||||
print 'debug: on_account_changed(): ' + new_account
|
||||
if self.accounts.has_key(new_account):
|
||||
self.username = new_account
|
||||
self.api = self.accounts[self.username]
|
||||
self.db['active_user'] = self.username
|
||||
self.update_account_label()
|
||||
|
||||
|
||||
|
|
Reference in New Issue
Block a user