Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1536

Show
Ignore:
Timestamp:
12/20/06 03:58:21
Author:
fumanchu
Message:

Moved check_compatibility into _cpchecker.py. Also allow disabling of Checker methods by setting them to None.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cpchecker.py

    r1535 r1536  
    1616                if name.startswith("check_"): 
    1717                    method = getattr(self, name) 
    18                     method() 
     18                    if method and callable(method): 
     19                        method() 
    1920        finally: 
    2021            warnings.formatwarning = oldformatwarning 
     
    7980                        warnings.warn("%s\nsection: [%s]\nroot: %r\ndir: %r" 
    8081                                      % (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) 
    81120 
  • trunk/cherrypy/_cpconfig.py

    r1535 r1536  
    249249 
    250250 
    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  
    281251 
    282252class _Parser(ConfigParser.ConfigParser): 
  • trunk/cherrypy/test/checkerdemo.py

    r1535 r1536  
    1414 
    1515if __name__ == '__main__': 
    16     conf = {'/base': {'tools.staticdir.root': thisdir}, 
     16    conf = {'/base': {'tools.staticdir.root': thisdir, 
     17                      # Obsolete key. 
     18                      'throw_errors': True, 
     19                      }, 
    1720            # This entry should be OK. 
    1821            '/base/static': {'tools.staticdir.on': True, 

Hosted by WebFaction

Log in as guest/cpguest to create tickets