Don't override the default profile when deleting that profile, and don't explode if a profile goes away

This commit is contained in:
Chris Jones 2010-05-15 16:00:09 +02:00
parent c64d71b809
commit 3aba98dade
1 changed files with 10 additions and 0 deletions

View File

@ -259,10 +259,16 @@ class Config(object):
def del_profile(self, profile):
"""Delete a profile"""
if profile == self.profile:
# FIXME: We should solve this problem by updating terminals when we
# remove a profile
err('Config::del_profile: Deleting in-use profile %s.' % profile)
self.set_profile('default')
if self.base.profiles.has_key(profile):
del(self.base.profiles[profile])
options = self.options_get()
if options and options.profile == profile:
options.profile = None
self.options_set(options)
def rename_profile(self, profile, newname):
"""Rename a profile"""
@ -600,6 +606,10 @@ class ConfigBase(Borg):
def get_item(self, key, profile='default', plugin=None):
"""Look up a configuration item"""
if not self.profiles.has_key(profile):
# Hitting this generally implies a bug
profile = 'default'
if self.global_config.has_key(key):
dbg('ConfigBase::get_item: %s found in globals: %s' %
(key, self.global_config[key]))