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

Changeset 1601

Show
Ignore:
Timestamp:
01/20/07 02:00:25
Author:
fumanchu
Message:

Bah. I meant to fix help(cherrypy.request) all along for CP 3 final and never got around to it. Here it is, finally; had to monkeypatch pydoc.resolve.

Files:

Legend:

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

    r1596 r1601  
    102102# Create thread_data object as a thread-specific all-purpose storage 
    103103thread_data = _local() 
     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). 
     110def _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 
     116try: 
     117    import pydoc 
     118    pydoc._builtin_resolve = pydoc.resolve 
     119    pydoc.resolve = _cherrypy_pydoc_resolve 
     120except ImportError: 
     121    pass 
    104122 
    105123 

Hosted by WebFaction

Log in as guest/cpguest to create tickets