Edgewall Software

Ticket #8510: config-cache.patch

File config-cache.patch, 1.5 KB (added by mixedpuppy <shanec@…>, 3 years ago)

updated patch

  • vendor/trac/trac/config.py

     
    4950        self._lastmtime = 0 
    5051        self._sections = {} 
    5152        self.parse_if_needed() 
     53        self._cache = {} 
    5254 
    5355    def __contains__(self, name): 
    5456        """Return whether the configuration contains a section of the given 
     
    247250        elif self.parent: 
    248251            changed = True 
    249252            self.parent = None 
    250  
     253        if changed: 
     254            self._cache = {} 
    251255        return changed 
    252256 
    253257    def touch(self): 
     
    294298        return '<Section [%s]>' % (self.name) 
    295299 
    296300    def get(self, name, default=''): 
     301        key = (self.name, name) 
     302        value = self.config._cache.get(key, default) 
     303        if value == default: 
     304            value = self._get(name, default) 
     305            if value != default: 
     306                self.config._cache[key] = value 
     307        return value 
     308             
     309    def _get(self, name, default=''): 
    297310        """Return the value of the specified option. 
    298311         
    299312        Valid default input is a string. Returns a string. 
     
    401414         
    402415        These changes are not persistent unless saved with `save()`. 
    403416        """ 
     417        key = (self.name, name) 
     418        if key in self.config._cache: 
     419            del self.config._cache[key] 
    404420        if not self.config.parser.has_section(self.name): 
    405421            self.config.parser.add_section(self.name) 
    406422        if value is None: