| | 104 | |
|---|
| | 105 | |
|---|
| | 106 | # Monkeypatch pydoc to allow help() to go through the threadlocal proxy. |
|---|
| | 107 | # Jan 2007: no Googleable examples of anyone else replacing pydoc.resolve. |
|---|
| | 108 | # The only other way would be to change what is returned from type(request) |
|---|
| | 109 | # and that's not possible in pure Python (you'd have to fake ob_type). |
|---|
| | 110 | def _cherrypy_pydoc_resolve(thing, forceload=0): |
|---|
| | 111 | """Given an object or a path to an object, get the object and its name.""" |
|---|
| | 112 | if isinstance(thing, _ThreadLocalProxy): |
|---|
| | 113 | thing = thing._get_child() |
|---|
| | 114 | return pydoc._builtin_resolve(thing, forceload) |
|---|
| | 115 | |
|---|
| | 116 | try: |
|---|
| | 117 | import pydoc |
|---|
| | 118 | pydoc._builtin_resolve = pydoc.resolve |
|---|
| | 119 | pydoc.resolve = _cherrypy_pydoc_resolve |
|---|
| | 120 | except ImportError: |
|---|
| | 121 | pass |
|---|