Edgewall Software

Ticket #3833: env_reload_5342.diff

File env_reload_5342.diff, 2.0 KB (added by osimons <simon-code@…>, 21 months ago)

Patch that solves arbitrary reload of individual projects after updating trac.ini without server restart (for servers that persist memory between requests). Patch is for 0.10-stable revision 5342.

  • Users/simon/dev/svn_out/trac-0.10-stable/trac/config.py

     
    173173        finally: 
    174174            fileobj.close() 
    175175 
    176     def parse_if_needed(self): 
     176    def parse_if_needed(self, check_only=False): 
    177177        # Load global configuration 
     178        # Alternatively, if check_only it returns True if it needs updating 
    178179        if os.path.isfile(self.site_filename): 
    179180            modtime = os.path.getmtime(self.site_filename) 
    180181            if modtime > self._lastsitemtime: 
     182                if check_only: 
     183                    return True 
    181184                self.site_parser.read(self.site_filename) 
    182185                self._lastsitemtime = modtime 
    183186 
     
    185188            return 
    186189        modtime = os.path.getmtime(self.filename) 
    187190        if modtime > self._lastmtime: 
     191            if check_only: 
     192                return True 
    188193            self.parser.read(self.filename) 
    189194            self._lastmtime = modtime 
    190195 
  • Users/simon/dev/svn_out/trac-0.10-stable/trac/web/main.py

     
    5454    env = None 
    5555    env_cache_lock.acquire() 
    5656    try: 
    57         if not env_path in env_cache: 
     57        if (not env_path in env_cache) or ( 
     58                env_cache[env_path].config.parse_if_needed(check_only=True)): 
    5859            env_cache[env_path] = open_environment(env_path) 
    5960        env = env_cache[env_path] 
    6061    finally: 
    6162        env_cache_lock.release() 
    6263 
    63     # Re-parse the configuration file if it changed since the last the time it 
    64     # was parsed 
    65     env.config.parse_if_needed() 
    66  
    6764    return env 
    6865 
    6966def populate_hdf(hdf, env, req=None):