Ticket #3833: env_reset.3.diff
| File env_reset.3.diff, 6.3 KB (added by cmlenz, 16 months ago) |
|---|
-
trac/env.py
516 516 env_cache_lock.acquire() 517 517 try: 518 518 env = env_cache.get(env_path) 519 if env and env.config.parse_if_needed(): 520 # The environment configuration has changed, so shut it down 521 # and remove it from the cache so that it gets reinitialized 522 env.shutdown() 523 if hasattr(env.log, '_trac_handler'): 524 env.log.removeHandler(env.log._trac_handler) 525 del env_cache[env_path] 526 env = None 519 527 if env is None: 520 528 env = env_cache.setdefault(env_path, open_environment(env_path)) 521 else:522 # Re-parse the configuration file if it changed since the last523 # the time it was parsed524 env.config.parse_if_needed()525 529 finally: 526 530 env_cache_lock.release() 527 531 else: -
trac/admin/web_ui.py
381 381 self._do_update(req) 382 382 anchor = '' 383 383 if req.args.has_key('plugin'): 384 anchor = '#no ' + req.args.get('plugin')384 anchor = '#no%d' % (int(req.args.get('plugin')) + 1) 385 385 req.redirect(req.href.admin(cat, page) + anchor) 386 386 387 387 return self._render_view(req) … … 426 426 427 427 # TODO: Validate that the uploaded file is actually a valid Trac plugin 428 428 429 # Make the environment reset itself on the next request 430 self.env.config.touch() 431 429 432 def _do_uninstall(self, req): 430 433 """Uninstall a plugin.""" 431 434 plugin_filename = req.args.get('plugin_filename') … … 437 440 self.log.info('Uninstalling plugin %s', plugin_filename) 438 441 os.remove(plugin_path) 439 442 443 # Make the environment reset itself on the next request 444 self.env.config.touch() 445 440 446 def _do_update(self, req): 441 447 """Update component enablement.""" 442 448 components = req.args.getlist('component') -
trac/admin/templates/admin_logging.html
52 52 <div class="buttons"> 53 53 <input type="submit" value="Apply changes"/> 54 54 </div> 55 <p class="help">56 You may need to restart the server for these changes to take effect.57 </p>58 55 </fieldset> 59 56 </form> 60 57 </body> -
trac/config.py
174 174 fileobj.close() 175 175 176 176 def parse_if_needed(self): 177 # Load global configuration178 177 if not self.filename or not os.path.isfile(self.filename): 179 return 178 return False 179 180 changed = False 180 181 modtime = os.path.getmtime(self.filename) 181 182 if modtime > self._lastmtime: 183 self.parser._sections = {} 182 184 self.parser.read(self.filename) 183 185 self._lastmtime = modtime 186 changed = True 184 187 185 188 if self.parser.has_option('inherit', 'file'): 186 189 filename = self.parser.get('inherit', 'file') … … 189 192 filename) 190 193 if not self.parent or self.parent.filename != filename: 191 194 self.parent = Configuration(filename) 195 changed = True 192 196 else: 193 self.parent.parse_if_needed()197 changed |= self.parent.parse_if_needed() 194 198 elif self.parent: 199 changed = True 195 200 self.parent = None 196 201 202 return changed 197 203 204 def touch(self): 205 os.utime(self.filename, None) 206 207 198 208 class Section(object): 199 209 """Proxy for a specific configuration section. 200 210 … … 292 302 """ 293 303 if self.config.parser.has_option(self.name, name): 294 304 path = self.config.parser.get(self.name, name) 295 if path and not os.path.isabs(path): 305 if not path: 306 return default 307 if not os.path.isabs(path): 296 308 path = os.path.join(os.path.dirname(self.config.filename), 297 309 path) 298 310 return os.path.normcase(os.path.realpath(path)) -
trac/tests/env.py
1 1 from trac import db_default 2 from trac.db import sqlite_backend 2 3 from trac.env import Environment 3 4 4 5 import os.path -
trac/log.py
44 44 format = '%(asctime)s ' + format 45 45 datefmt = '' 46 46 if logtype == 'stderr': 47 datefmt = '%X' 47 datefmt = '%X' 48 48 level = level.upper() 49 49 if level in ('DEBUG', 'ALL'): 50 50 logger.setLevel(logging.DEBUG) … … 58 58 logger.setLevel(logging.WARNING) 59 59 formatter = logging.Formatter(format, datefmt) 60 60 hdlr.setFormatter(formatter) 61 logger.addHandler(hdlr) 61 logger.addHandler(hdlr) 62 62 63 # Remember our handler so that we can remove it later 64 logger._trac_handler = hdlr 65 63 66 return logger -
trac/util/__init__.py
228 228 pkginfo = email.message_from_string(dist.get_metadata('PKG-INFO')) 229 229 for attr in [key for key in attrs if key in pkginfo]: 230 230 info[normalize(attr)] = pkginfo[attr] 231 except IOError, e: 232 err = 'Failed to read PKG-INFO file for %s: %s' % (dist, e) 233 for attr in attrs: 234 info[normalize(attr)] = err 231 235 except email.Errors.MessageError, e: 232 236 err = 'Failed to parse PKG-INFO file for %s: %s' % (dist, e) 233 237 for attr in attrs:
