diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py index 37f6c5a87373436450acf9211313bae67610cb2c..c94b6c7577d646fe4fbe99f8cda459010996843b 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py @@ -31,11 +31,8 @@ class NodeWithEntityType(Node): self.permIds.add(permId) class Acceptor(object): - def __init__(self, settings): + def __init__(self): self.sections = ["Lab Notebook", "Inventory", "Stock"] - self.inventorySpaces = settings.inventorySpaces - self.mainMenues = settings.mainMenues - self.sampleTypeViewAttributes = settings.sampleTypeViewAttributes self.endingsOfHiddenSpaces = [] self.hideSpaceEndingWith("ELN_SETTINGS") self.hideSpaceEndingWith("NAGIOS") @@ -45,6 +42,11 @@ class Acceptor(object): self.hiddenDataSetTypes = {} self.sampleChildrenHandlers = {} + def configure(self, settings): + self.inventorySpaces = settings.inventorySpaces + self.mainMenues = settings.mainMenues + self.sampleTypeViewAttributes = settings.sampleTypeViewAttributes + def assertValidSection(self, section): if section not in self.sections: raise NoSuchFileException("Invalid section '%s'." % section) @@ -117,8 +119,14 @@ class Settings(object): self.mainMenues = mainMenues self.sampleTypeViewAttributes = sampleTypeViewAttributes +acceptor = Acceptor() +pluginsFolder = "%s/resolver-plugins" % os.path.dirname(__file__) +for pluginFileName in os.listdir(pluginsFolder): + file = "%s/%s" % (pluginsFolder, pluginFileName) + execfile(file, {"acceptor":acceptor}) + def resolve(subPath, context): - acceptor = createAcceptor(context) + acceptor.configure(getAllSettings(context)) if len(subPath) == 0: return listSections(acceptor, context) @@ -141,14 +149,6 @@ def resolve(subPath, context): if len(subPath) > 4: return listChildren(subPath, acceptor, context) -def createAcceptor(context): - acceptor = Acceptor(getAllSettings(context)) - pluginsFolder = "%s/resolver-plugins" % os.path.dirname(__file__) - for pluginFileName in os.listdir(pluginsFolder): - file = "%s/%s" % (pluginsFolder, pluginFileName) - execfile(file, {"acceptor":acceptor}) - return acceptor - def listSections(acceptor, context): response = context.createDirectoryResponse() for section in acceptor.sections: