Changeset 1536
- Timestamp:
- 12/20/06 03:58:21
- Files:
-
- trunk/cherrypy/_cpchecker.py (modified) (2 diffs)
- trunk/cherrypy/_cpconfig.py (modified) (1 diff)
- trunk/cherrypy/test/checkerdemo.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpchecker.py
r1535 r1536 16 16 if name.startswith("check_"): 17 17 method = getattr(self, name) 18 method() 18 if method and callable(method): 19 method() 19 20 finally: 20 21 warnings.formatwarning = oldformatwarning … … 79 80 warnings.warn("%s\nsection: [%s]\nroot: %r\ndir: %r" 80 81 % (msg, section, root, dir)) 82 83 obsolete = { 84 'server.default_content_type': 'tools.response_headers.headers', 85 'log_access_file': 'log.access_file', 86 'log_config_options': None, 87 'log_file': 'log.error_file', 88 'log_file_not_found': None, 89 'log_request_headers': 'tools.log_headers.on', 90 'log_to_screen': 'log.screen', 91 'show_tracebacks': 'request.show_tracebacks', 92 'throw_errors': 'request.throw_errors', 93 'profiler.on': 'cherrypy.tree.mount(profiler.make_app(cherrypy.Application(Root())))', 94 } 95 96 deprecated = {} 97 98 def _compat(self, config): 99 """Process config and warn on each obsolete or deprecated entry.""" 100 for section, conf in config.iteritems(): 101 if isinstance(conf, dict): 102 for k, v in conf.iteritems(): 103 if k in self.obsolete: 104 warnings.warn("%r is obsolete. Use %r instead.\n" 105 "section: [%s]" % (k, v, section)) 106 elif k in self.deprecated: 107 warnings.warn("%r is deprecated. Use %r instead.\n" 108 "section: [%s]" % (k, v, section)) 109 else: 110 if section in self.obsolete: 111 warnings.warn("%r is obsolete. Use %r instead." % (section, conf)) 112 elif section in self.deprecated: 113 warnings.warn("%r is deprecated. Use %r instead." % (section, conf)) 114 115 def check_compatibility(self): 116 """Process config and warn on each obsolete or deprecated entry.""" 117 self._compat(cherrypy.config) 118 for sn, app in cherrypy.tree.apps.iteritems(): 119 self._compat(app.config) 81 120 trunk/cherrypy/_cpconfig.py
r1535 r1536 249 249 250 250 251 obsolete = {252 'server.default_content_type': 'tools.response_headers.headers',253 'log_access_file': 'log.access_file',254 'log_config_options': None,255 'log_file': 'log.error_file',256 'log_file_not_found': None,257 'log_request_headers': 'tools.log_headers.on',258 'log_to_screen': 'log.screen',259 'show_tracebacks': 'request.show_tracebacks',260 'throw_errors': 'request.throw_errors',261 'profiler.on': 'cherrypy.tree.mount(profiler.make_app(cherrypy.Application(Root())))',262 }263 264 deprecated = {}265 266 def check_compatibility(config):267 """Process config and warn on each obsolete or deprecated entry."""268 for section, map in as_dict(config).iteritems():269 if isinstance(map, dict):270 for k, v in map.iteritems():271 if k in obsolete:272 warn("%r is obsolete. Use %r instead." % (k, v))273 elif k in deprecated:274 warn("%r is deprecated. Use %r instead." % (k, v))275 else:276 if section in obsolete:277 warn("%r is obsolete. Use %r instead." % (section, map))278 elif section in deprecated:279 warn("%r is deprecated. Use %r instead." % (section, map))280 281 251 282 252 class _Parser(ConfigParser.ConfigParser): trunk/cherrypy/test/checkerdemo.py
r1535 r1536 14 14 15 15 if __name__ == '__main__': 16 conf = {'/base': {'tools.staticdir.root': thisdir}, 16 conf = {'/base': {'tools.staticdir.root': thisdir, 17 # Obsolete key. 18 'throw_errors': True, 19 }, 17 20 # This entry should be OK. 18 21 '/base/static': {'tools.staticdir.on': True,

