示例#1
0
 def contains(self, key, defaults=True):
     key = self.optionxform(key)
     if ProductSetting.exists(self.env, self.product, self.name, key):
         return True
     for parent in self.config.parents:
         if parent[self.name].contains(key, defaults=False):
             return True
     return defaults and (self.name, key) in Option.registry
示例#2
0
 def contains(self, key, defaults=True):
     key = self.optionxform(key)
     if ProductSetting.exists(self.env, self.product, self.name, key):
         return True
     for parent in self.config.parents:
         if parent[self.name].contains(key, defaults=False):
             return True
     return defaults and Option.registry.has_key((self.name, key))
示例#3
0
    def has_option(self, section, option, defaults=True):
        """Returns True if option exists in section in either the project
        trac.ini or one of the parents, or is available through the Option
        registry.

        (since Trac 0.11)
        """
        if ProductSetting.exists(self.env, self.product, section, option):
            return True
        for parent in self.parents:
            if parent.has_option(section, option, defaults=False):
                return True
        return defaults and (section, option) in Option.registry
示例#4
0
    def has_option(self, section, option, defaults=True):
        """Returns True if option exists in section in either the project
        trac.ini or one of the parents, or is available through the Option
        registry.

        (since Trac 0.11)
        """
        if ProductSetting.exists(self.env, self.product, section, option):
            return True
        for parent in self.parents:
            if parent.has_option(section, option, defaults=False):
                return True
        return defaults and (section, option) in Option.registry
示例#5
0
    def set_defaults(self, compmgr=None):
        """Retrieve all default values and store them explicitly in the
        configuration, so that they can be saved to file.

        Values already set in the configuration are not overridden.
        """
        for section, default_options in self.defaults(compmgr).items():
            for name, value in default_options.items():
                if not ProductSetting.exists(self.env, self.product,
                                             section, name):
                    if any(parent[section].contains(name, defaults=False)
                           for parent in self.parents):
                        value = None
                    self.set(section, name, value)
示例#6
0
    def set_defaults(self, compmgr=None):
        """Retrieve all default values and store them explicitly in the
        configuration, so that they can be saved to file.

        Values already set in the configuration are not overridden.
        """
        for section, default_options in self.defaults(compmgr).items():
            for name, value in default_options.items():
                if not ProductSetting.exists(self.env, self.product, section,
                                             name):
                    if any(parent[section].contains(name, defaults=False)
                           for parent in self.parents):
                        value = None
                    self.set(section, name, value)