Ticket #3833: env_reset.3.osimons.diff
| File env_reset.3.osimons.diff, 6.0 KB (added by osimons <simon-code@…>, 16 months ago) |
|---|
-
trac/env.py
329 329 .replace('%(path)s', self.path) \ 330 330 .replace('%(basename)s', os.path.basename(self.path)) \ 331 331 .replace('%(project)s', self.project_name) 332 self.log = logger_factory(logtype, logfile, self.log_level, self.path,333 format=format)332 self.log, self._log_hdlr = logger_factory(logtype, logfile, 333 self.log_level, self.path, format=format) 334 334 335 335 def get_known_users(self, cnx=None): 336 336 """Generator that yields information about all known users, i.e. users … … 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 is dirty - shut it down and remove from cache 521 env.shutdown() 522 env.log.removeHandler(env._log_hdlr) 523 env_cache.pop(env_path) 524 env = None 519 525 if env is None: 520 526 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 527 finally: 526 528 env_cache_lock.release() 527 529 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/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) … … 60 60 hdlr.setFormatter(formatter) 61 61 logger.addHandler(hdlr) 62 62 63 return logger 63 return logger, hdlr -
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:
