Changeset 1373
- Timestamp:
- 09/22/06 20:26:45
- Files:
-
- trunk/cherrypy/_cpconfig.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpconfig.py
r1369 r1373 78 78 79 79 import ConfigParser 80 from warnings import warn 81 80 82 import cherrypy 81 83 … … 101 103 } 102 104 105 def as_dict(config): 106 """Return a dict from 'config' whether it is a dict, file, or filename.""" 107 if isinstance(config, basestring): 108 config = _Parser().dict_from_file(config) 109 elif hasattr(config, 'read'): 110 config = _Parser().dict_from_file(config) 111 return config 112 103 113 def merge(base, other): 104 """Merge one app config (from a dict, file, or filename) into another.""" 114 """Merge one app config (from a dict, file, or filename) into another. 115 116 If the given config is a filename, it will be appended to 117 cherrypy.engine.reload_files and monitored for changes. 118 """ 105 119 if isinstance(other, basestring): 106 120 if other not in cherrypy.engine.reload_files: 107 121 cherrypy.engine.reload_files.append(other) 108 other = _Parser().dict_from_file(other)109 elif hasattr(other, 'read'):110 other = _Parser().dict_from_file(other)111 122 112 123 # Load other into base 113 for section, value_map in other.iteritems():124 for section, value_map in as_dict(other).iteritems(): 114 125 base.setdefault(section, {}).update(value_map) 115 126 … … 174 185 if namespace in self.namespaces: 175 186 self.namespaces[namespace](atoms[1], v) 187 188 189 obsolete = { 190 'server.default_content_type': 'tools.response_headers.headers', 191 'log_access_file': 'log.access_file', 192 'log_config_options': None, 193 'log_file': 'log.error_file', 194 'log_file_not_found': None, 195 'log_request_headers': 'tools.log_headers.on', 196 'log_to_screen': 'log.screen', 197 'show_tracebacks': 'request.show_tracebacks', 198 'throw_errors': 'request.throw_errors', 199 'profiler.on': 'cherrypy.tree.mount(profiler.make_app(cherrypy.Application(Root())))', 200 } 201 202 deprecated = {} 203 204 def check_compatibility(config): 205 """Process config and warn on each obsolete or deprecated entry.""" 206 for section, map in as_dict(config).iteritems(): 207 if isinstance(map, dict): 208 for k, v in map.iteritems(): 209 if k in obsolete: 210 warn("%r is obsolete. Use %r instead." % (k, v)) 211 elif k in deprecated: 212 warn("%r is deprecated. Use %r instead." % (k, v)) 213 else: 214 if section in obsolete: 215 warn("%r is obsolete. Use %r instead." % (section, map)) 216 elif section in deprecated: 217 warn("%r is deprecated. Use %r instead." % (section, map)) 176 218 177 219

