Ticket #3833: env_reset.diff
| File env_reset.diff, 6.7 KB (added by cmlenz, 16 months ago) |
|---|
-
trac/core.py
1 1 # -*- coding: utf-8 -*- 2 2 # 3 # Copyright (C) 2003-200 5Edgewall Software3 # Copyright (C) 2003-2007 Edgewall Software 4 4 # Copyright (C) 2003-2004 Jonas Borgström <jonas@edgewall.com> 5 # Copyright (C) 2004-200 5Christopher Lenz <cmlenz@gmx.de>5 # Copyright (C) 2004-2007 Christopher Lenz <cmlenz@gmx.de> 6 6 # All rights reserved. 7 7 # 8 8 # This software is licensed as described in the file COPYING, which … … 24 24 """Exception base class for errors in Trac.""" 25 25 26 26 title = 'Trac Error' 27 27 28 28 def __init__(self, message, title=None, show_traceback=False): 29 29 """If message is a genshi.builder.tag object, everything up to the 30 30 first <p> will be displayed in the red box, and everything after will … … 218 218 not be available. 219 219 """ 220 220 return True 221 222 def reset(self): 223 self.components = {} 224 self.enabled = {} -
trac/env.py
23 23 import sys 24 24 from urlparse import urlsplit 25 25 26 from trac import db_default 26 from trac import db_default, loader 27 27 from trac.config import * 28 28 from trac.core import Component, ComponentManager, implements, Interface, \ 29 29 ExtensionPoint, TracError … … 167 167 ] 168 168 self._href = self._abs_href = None 169 169 170 from trac.loader import load_components171 plugins_dir = self.config.get('inherit', 'plugins_dir')172 load_components(self, plugins_dir and (plugins_dir,))173 174 170 if create: 175 171 self.create(options) 176 172 else: 177 173 self.verify() 178 174 175 self._load_components() 176 179 177 if create: 180 178 for setup_participant in self.setup_participants: 181 179 setup_participant.environment_created() … … 225 223 # By default, all components in the trac package are enabled 226 224 return component_name.startswith('trac.') 227 225 226 def reset(self): 227 ComponentManager.reset(self) 228 self._load_components() 229 228 230 def verify(self): 229 231 """Verify that the provided path points to a valid Trac environment 230 232 directory.""" … … 429 431 return self._abs_href 430 432 abs_href = property(_get_abs_href, 'The application URL') 431 433 434 def _load_components(self): 435 plugins_dir = self.shared_plugins_dir 436 loader.load_components(self, plugins_dir and (plugins_dir,)) 432 437 438 433 439 class EnvironmentSetup(Component): 434 440 implements(IEnvironmentSetupParticipant) 435 441 … … 521 527 else: 522 528 # Re-parse the configuration file if it changed since the last 523 529 # the time it was parsed 524 env.config.parse_if_needed() 530 if env.config.parse_if_needed(): 531 env.reset() 525 532 finally: 526 533 env_cache_lock.release() 527 534 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
173 173 finally: 174 174 fileobj.close() 175 175 176 def parse_if_needed(self): 177 # Load global configuration 176 def parse_if_needed(self, check_only=False): 178 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: 182 183 self.parser.read(self.filename) 183 184 self._lastmtime = modtime 185 changed = True 184 186 185 187 if self.parser.has_option('inherit', 'file'): 186 188 filename = self.parser.get('inherit', 'file') … … 189 191 filename) 190 192 if not self.parent or self.parent.filename != filename: 191 193 self.parent = Configuration(filename) 194 changed = True 192 195 else: 193 self.parent.parse_if_needed()196 changed |= self.parent.parse_if_needed(check_only=check_only) 194 197 elif self.parent: 198 changed = True 195 199 self.parent = None 196 200 201 return changed 197 202 203 def touch(self): 204 os.utime(self.filename, None) 205 206 198 207 class Section(object): 199 208 """Proxy for a specific configuration section. 200 209 -
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) -
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:
