improved the way how to avoid recursion in volume_properties

added useful result of get_status
This commit is contained in:
lars 2007-01-29 00:55:20 +00:00
parent 0147531012
commit 6d0975d32f

View file

@ -35,9 +35,12 @@ class volume_props(cryptobox.plugins.base.CryptoBoxPlugin):
def do_action(self, **args): def do_action(self, **args):
import os import os
## include all plugins marked as "properties"
## skip ourselves to prevent recursion
self.props_plugins = [e for e in cryptobox.plugins.manage.PluginManager(self.cbox, self.props_plugins = [e for e in cryptobox.plugins.manage.PluginManager(self.cbox,
self.cbox.prefs["Locations"]["PluginDir"]).get_plugins() self.cbox.prefs["Locations"]["PluginDir"]).get_plugins()
if "properties" in e.get_visibility()] if ("properties") in (e.get_visibility()) \
and (e.get_name() != self.get_name())]
## sort plugins by rank ## sort plugins by rank
self.props_plugins.sort(cmp = self.__cmp_plugins_rank) self.props_plugins.sort(cmp = self.__cmp_plugins_rank)
## set the name of the templates for every plugin ## set the name of the templates for every plugin
@ -47,9 +50,6 @@ class volume_props(cryptobox.plugins.base.CryptoBoxPlugin):
## (e.g. chpasswd for plain containers) ## (e.g. chpasswd for plain containers)
if not p.is_useful(self.device): if not p.is_useful(self.device):
continue continue
## prevent recursion
if p.get_name() == self.get_name():
continue
p.device = self.device p.device = self.device
plfname = os.path.join(p.plugin_dir, str(p.do_action(**args)) + ".cs") plfname = os.path.join(p.plugin_dir, str(p.do_action(**args)) + ".cs")
#load_string += "<fieldset><legend><?cs var:html_escape(Lang.Plugins.%s.Link) ?></legend><?cs include:'%s' ?></fieldset>" \ #load_string += "<fieldset><legend><?cs var:html_escape(Lang.Plugins.%s.Link) ?></legend><?cs include:'%s' ?></fieldset>" \
@ -67,20 +67,17 @@ class volume_props(cryptobox.plugins.base.CryptoBoxPlugin):
def get_status(self): def get_status(self):
return "TODO" return ":".join([ e.get_name() for e in self.props_plugins ])
def load_dataset(self, hdf): def load_dataset(self, hdf):
"""override the parent's function """Override the parent's function
we have to get the data from all included plugins"""
we have to get the data from all included plugins
"""
for plugin in self.props_plugins: for plugin in self.props_plugins:
## TODO: this leads to strange behaviour if volume_props ## retrieve the results of an included plugin
## is configured to show itself inside itself. plugin.load_dataset(hdf)
## As volume_props works without this, I commented this
## out. If it is really needed, there should be a check if
## this plugin is trying to load the dataset of itself.
#plugin.load_dataset(hdf)
pass
## call our parent's method ## call our parent's method
cryptobox.plugins.base.CryptoBoxPlugin.load_dataset(self, hdf) cryptobox.plugins.base.CryptoBoxPlugin.load_dataset(self, hdf)