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

Changeset 1544

Show
Ignore:
Timestamp:
12/21/06 01:41:06
Author:
fumanchu
Message:

More checker checks (plus a fix for the fix for the fix).

Files:

Legend:

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

    r1543 r1544  
    113113                elif section in self.deprecated: 
    114114                    warnings.warn("%r is deprecated. Use %r instead." 
    115                                   % (section, self.decprecated[section])) 
     115                                  % (section, self.deprecated[section])) 
    116116     
    117117    def check_compatibility(self): 
     
    120120        for sn, app in cherrypy.tree.apps.iteritems(): 
    121121            self._compat(app.config) 
    122  
     122     
     123    known_config_namespaces = ["engine", "hooks", "log", "request", 
     124                               "response", "server", "tools", "wsgi"] 
     125     
     126    def _known_ns(self, config): 
     127        for section, conf in config.iteritems(): 
     128            is_path_section = section.startswith("/") 
     129            if is_path_section and isinstance(conf, dict): 
     130                for k, v in conf.iteritems(): 
     131                    atoms = k.split(".") 
     132                    if len(atoms) > 1: 
     133                        if atoms[0] not in self.known_config_namespaces: 
     134                            if atoms[0] == "cherrypy" and atoms[1] in self.known_config_namespaces: 
     135                                msg = ("The config entry %r is invalid; " 
     136                                       "try %r instead.\nsection: [%s]" 
     137                                       % (k, ".".join(atoms[1:]), section)) 
     138                            else: 
     139                                msg = ("The config entry %r is invalid, because " 
     140                                       "the %r config namespace is unknown.\n" 
     141                                       "section: [%s]" % (k, atoms[0], section)) 
     142                            warnings.warn(msg) 
     143     
     144    def check_config_namespaces(self): 
     145        """Process config and warn on each unknown config namespace.""" 
     146        for sn, app in cherrypy.tree.apps.iteritems(): 
     147            self._known_ns(app.config) 
  • trunk/cherrypy/test/checkerdemo.py

    r1536 r1544  
    3030            '/static3': {'tools.staticdir.on': True, 
    3131                         'tools.staticdir.dir': 'static'}, 
     32            # Warn on unknown namespace 
     33            '/unknown': {'toobles.gzip.on': True}, 
     34            # Warn special on cherrypy.<known ns>.* 
     35            '/cpknown': {'cherrypy.tools.encode.on': True}, 
    3236            } 
    3337    cherrypy.quickstart(Root(), config=conf) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets