1. Irina Gavrilova
  2. CherryPy


Robert Brewer  committed b61134c

Fix for #716 (Checker should warn on unknown tool).

  • Participants
  • Parent commits 6f09ab7
  • Branches cherrypy-3.0.x

Comments (0)

Files changed (2)

File cherrypy/_cpchecker.py

View file
                     atoms = k.split(".")
                     if len(atoms) > 1:
                         if atoms[0] not in ns:
+                            # Spit out a special warning if a known
+                            # namespace is preceded by "cherrypy."
                             if (atoms[0] == "cherrypy" and atoms[1] in ns):
                                 msg = ("The config entry %r is invalid; "
                                        "try %r instead.\nsection: [%s]"
                                        "the %r config namespace is unknown.\n"
                                        "section: [%s]" % (k, atoms[0], section))
+                        elif atoms[0] == "tools":
+                            if atoms[1] not in dir(cherrypy.tools):
+                                msg = ("The config entry %r may be invalid, "
+                                       "because the %r tool was not found.\n"
+                                       "section: [%s]" % (k, atoms[1], section))
+                                warnings.warn(msg)
     def check_config_namespaces(self):
         """Process config and warn on each unknown config namespace."""

File cherrypy/test/checkerdemo.py

View file
             '/cpknown': {'cherrypy.tools.encode.on': True},
             # Warn on mismatched types
             '/conftype': {'request.show_tracebacks': 14},
+            # Warn on unknown tool.
+            '/web': {'tools.unknown.on': True},
     cherrypy.quickstart(Root(), config=conf)