示例#1
0
文件: meta.py 项目: Trixter69/XDM
    def getConfigsFor(self, element):
        out = []
        for cur_element in element.ancestors:
            # print "checking ancestor '%s' from '%s'" % (cur_element, element)
            for k, v in self._configDefinition.items():
                try:
                    cur_c = Config.get(
                        Config.section == self._plugin.__class__.__name__,
                        Config.module == "Plugin",
                        Config.instance == self._plugin.instance,
                        Config.name == k,
                        Config.element == cur_element,
                    )
                except Config.DoesNotExist:
                    continue
                out.append(cur_c)
                self.addConfig(cur_c)
            # print "element configs for %s" % element
        if out:
            # for c in out:
            #    print c
            return out

        for k, v in self._configDefinition.items():
            try:
                cur_c = Config.get(
                    Config.section == self._plugin.__class__.__name__,
                    Config.module == "Plugin",
                    Config.instance == self._plugin.instance,
                    Config.name == k,
                    Config.element == element,
                )
            except Config.DoesNotExist:
                cur_c = Config()
                cur_c.module = "Plugin"
                cur_c.section = self._plugin.__class__.__name__
                cur_c.instance = self._plugin.instance
                cur_c.name = k
                if v == k:
                    v = getattr(self._plugin.c, v)
                cur_c.value = v
                cur_c.type = "element_config"
                cur_c.element = element
                cur_c.save()
            out.append(cur_c)
            self.addConfig(cur_c)
        # print "element configs for %s" % element
        # for c in out:
        #    print c
        return out
示例#2
0
    def getConfigsFor(self, element):
        out = []
        for cur_element in element.ancestors:
            print "checking ancestor '%s' from '%s'" % (cur_element, element)
            for k, v in self._configDefinition.items():
                try:
                    cur_c = Config.get(
                        Config.section == self._plugin.__class__.__name__,
                        Config.module == 'Plugin',
                        Config.instance == self._plugin.instance,
                        Config.name == k, Config.element == cur_element)
                except Config.DoesNotExist:
                    continue
                out.append(cur_c)
                self.addConfig(cur_c)
            # print "element configs for %s" % element
        if out:
            for c in out:
                print c
            return out

        for k, v in self._configDefinition.items():
            try:
                cur_c = Config.get(
                    Config.section == self._plugin.__class__.__name__,
                    Config.module == 'Plugin',
                    Config.instance == self._plugin.instance, Config.name == k,
                    Config.element == element)
            except Config.DoesNotExist:
                cur_c = Config()
                cur_c.module = 'Plugin'
                cur_c.section = self._plugin.__class__.__name__
                cur_c.instance = self._plugin.instance
                cur_c.name = k
                if v == k:
                    v = getattr(self._plugin.c, v)
                cur_c.value = v
                cur_c.type = 'element_config'
                cur_c.element = element
                cur_c.save()
            out.append(cur_c)
            self.addConfig(cur_c)
        # print "element configs for %s" % element
        for c in out:
            print c
        return out
示例#3
0
文件: meta.py 项目: chr1831/XDM
 def getConfigsFor(self, element):
     out = []
     for k, v in self._configDefinition.items():
         try:
             cur_c = Config.get(Config.section == self._plugin.__class__.__name__,
                                Config.module == 'Plugin',
                                Config.instance == self._plugin.instance,
                                Config.name == k,
                                Config.element == element)
         except Config.DoesNotExist:
             cur_c = Config()
             cur_c.module = 'Plugin'
             cur_c.section = self._plugin.__class__.__name__
             cur_c.instance = self._plugin.instance
             cur_c.name = k
             if v == k:
                 v = getattr(self._plugin.c, v)
             cur_c.value = v
             cur_c.type = 'element_config'
             cur_c.element = element
             cur_c.save()
         out.append(cur_c)
         self.addConfig(cur_c)
     return out
示例#4
0
 def getConfigsFor(self, element):
     out = []
     for k, v in self._configDefinition.items():
         try:
             cur_c = Config.get(
                 Config.section == self._plugin.__class__.__name__,
                 Config.module == 'Plugin',
                 Config.instance == self._plugin.instance, Config.name == k,
                 Config.element == element)
         except Config.DoesNotExist:
             cur_c = Config()
             cur_c.module = 'Plugin'
             cur_c.section = self._plugin.__class__.__name__
             cur_c.instance = self._plugin.instance
             cur_c.name = k
             if v == k:
                 v = getattr(self._plugin.c, v)
             cur_c.value = v
             cur_c.type = 'element_config'
             cur_c.element = element
             cur_c.save()
         out.append(cur_c)
         self.addConfig(cur_c)
     return out