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):
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.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
self.props_plugins.sort(cmp = self.__cmp_plugins_rank)
## 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)
if not p.is_useful(self.device):
continue
## prevent recursion
if p.get_name() == self.get_name():
continue
p.device = self.device
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>" \
@ -67,20 +67,17 @@ class volume_props(cryptobox.plugins.base.CryptoBoxPlugin):
def get_status(self):
return "TODO"
return ":".join([ e.get_name() for e in self.props_plugins ])
def load_dataset(self, hdf):
"""override the parent's function
we have to get the data from all included plugins"""
"""Override the parent's function
we have to get the data from all included plugins
"""
for plugin in self.props_plugins:
## TODO: this leads to strange behaviour if volume_props
## is configured to show itself inside itself.
## 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
## retrieve the results of an included plugin
plugin.load_dataset(hdf)
## call our parent's method
cryptobox.plugins.base.CryptoBoxPlugin.load_dataset(self, hdf)