volume name changed allowed even if it is active

load _all_ plugin language data -> simplifies code
This commit is contained in:
lars 2006-11-13 16:12:19 +00:00
parent 46e10ee6d4
commit c12057d4c4
2 changed files with 11 additions and 24 deletions

View file

@ -54,8 +54,9 @@ class CryptoBoxContainer:
def setName(self, new_name): def setName(self, new_name):
if new_name == self.name: return if new_name == self.name: return
if self.isMounted(): # TODO: check why the following test was/is (?) necessary - side effects?
raise CBVolumeIsActive("the container must be inactive during renaming") #if self.isMounted():
# raise CBVolumeIsActive("the container must be inactive during renaming")
if not re.search(r'^[a-zA-Z0-9_\.\- ]+$', new_name): if not re.search(r'^[a-zA-Z0-9_\.\- ]+$', new_name):
raise CBInvalidName("the supplied new name contains illegal characters") raise CBInvalidName("the supplied new name contains illegal characters")
"check for active partitions with the same name" "check for active partitions with the same name"

View file

@ -142,7 +142,7 @@ class WebInterfaceSites:
except KeyError: except KeyError:
self.__setWebLang("") self.__setWebLang("")
## we always read the "device" setting - otherwise volume-plugin links ## we always read the "device" setting - otherwise volume-plugin links
## would not work easily (see "volume_props" linking to "format_fs") ## would not work easily (see "volume_props" linking to "volume_format_fs")
## it will get ignored for non-volume plugins ## it will get ignored for non-volume plugins
try: try:
plugin.device = None plugin.device = None
@ -213,11 +213,6 @@ class WebInterfaceSites:
valueDict["message_keep"]["dataset"][keep_key] = plugin.hdf[keep_key] valueDict["message_keep"]["dataset"][keep_key] = plugin.hdf[keep_key]
new_plugin = self.pluginList.getPlugin(nextTemplate["plugin"]) new_plugin = self.pluginList.getPlugin(nextTemplate["plugin"])
return self.return_plugin_action(new_plugin)(**valueDict) return self.return_plugin_action(new_plugin)(**valueDict)
## did we want to keep some dataset values? then save the specified plugin
if keep_values:
if type(nextTemplate) == types.StringType:
nextTemplate = { "template":nextTemplate }
nextTemplate["old_plugin"] = keep_values["plugin"]
## save the currently active plugin name ## save the currently active plugin name
self.dataset["Data.ActivePlugin"] = plugin.getName() self.dataset["Data.ActivePlugin"] = plugin.getName()
return self.__render(nextTemplate, plugin) return self.__render(nextTemplate, plugin)
@ -388,16 +383,12 @@ class WebInterfaceSites:
## is renderInfo a string (filename of the template) or a dictionary? ## is renderInfo a string (filename of the template) or a dictionary?
if type(renderInfo) == types.DictType: if type(renderInfo) == types.DictType:
template = renderInfo["template"] template = renderInfo["template"]
if renderInfo.has_key("old_plugin"):
old_plugin = renderInfo["old_plugin"]
else:
old_plugin = None
if renderInfo.has_key("generator"): if renderInfo.has_key("generator"):
generator = renderInfo["generator"] generator = renderInfo["generator"]
else: else:
generator = None generator = None
else: else:
(template, generator, old_plugin) = (renderInfo, None, None) (template, generator) = (renderInfo, None)
## load the language data ## load the language data
hdf = neo_util.HDF() hdf = neo_util.HDF()
@ -406,6 +397,12 @@ class WebInterfaceSites:
## first: assume, that the template file is in the global template directory ## first: assume, that the template file is in the global template directory
self.dataset["Settings.TemplateFile"] = os.path.abspath(os.path.join(self.prefs["Locations"]["TemplateDir"], template + ".cs")) self.dataset["Settings.TemplateFile"] = os.path.abspath(os.path.join(self.prefs["Locations"]["TemplateDir"], template + ".cs"))
## load the language data of all plugins
for p in self.pluginList.getPlugins():
pl_lang = p.getLanguageData(self.dataset["Settings.Language"])
if pl_lang:
hdf.copy("Lang.Plugins.%s" % p.getName(), pl_lang)
if plugin: if plugin:
## check, if the plugin provides the template file -> overriding ## check, if the plugin provides the template file -> overriding
plugin_cs_file = plugin.getTemplateFileName(template) plugin_cs_file = plugin.getTemplateFileName(template)
@ -414,17 +411,6 @@ class WebInterfaceSites:
## add the current state of the plugins to the hdf dataset ## add the current state of the plugins to the hdf dataset
self.dataset["Data.Status.Plugins.%s" % plugin.getName()] = plugin.getStatus() self.dataset["Data.Status.Plugins.%s" % plugin.getName()] = plugin.getStatus()
## load the language data
pl_lang = plugin.getLanguageData(self.dataset["Settings.Language"])
if pl_lang:
self.cbox.log.info("load plugin language: %s" % plugin.getName())
hdf.copy("Lang.Plugins.%s" % plugin.getName(), pl_lang)
## was there an "old_plugin"? then load its language data, too
if old_plugin and (old_plugin != plugin):
pl_lang = old_plugin.getLanguageData(self.dataset["Settings.Language"])
if pl_lang:
self.cbox.log.info("load old plugin language: %s" % old_plugin.getName())
hdf.copy("Lang.Plugins.%s" % old_plugin.getName(), pl_lang)
## load the dataset of the plugin ## load the dataset of the plugin
plugin.loadDataSet(hdf) plugin.loadDataSet(hdf)