Edgewall Software

Ticket #5135: config-reparse-with-section-delete.diff

File config-reparse-with-section-delete.diff, 1007 bytes (added by simon-code@…, 5 years ago)

Patch for removing specific sections before re-parsing config.

  • trac/config.py

    old new  
    174174            fileobj.close() 
    175175 
    176176    def parse_if_needed(self): 
     177        # Sections to completely reload (to allow for options being removed) 
     178        sections_to_delete = ['ticket-custom'] 
     179         
    177180        # Load global configuration 
    178181        if os.path.isfile(self.site_filename): 
    179182            modtime = os.path.getmtime(self.site_filename) 
    180183            if modtime > self._lastsitemtime: 
     184                for section in sections_to_delete: 
     185                    self.site_parser.remove_section(section) 
    181186                self.site_parser.read(self.site_filename) 
    182187                self._lastsitemtime = modtime 
    183188 
     
    185190            return 
    186191        modtime = os.path.getmtime(self.filename) 
    187192        if modtime > self._lastmtime: 
     193            for section in sections_to_delete: 
     194                self.parser.remove_section(section) 
    188195            self.parser.read(self.filename) 
    189196            self._lastmtime = modtime 
    190197