| 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) |
|---|