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

Changeset 1497

Show
Ignore:
Timestamp:
12/09/06 17:12:30
Author:
fumanchu
Message:

2.x backport of [1142] (Removed inspect import in cherrypy.lib.cptools.decorate, decorateAll.)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-2.x/cherrypy/lib/cptools.py

    r1492 r1497  
    11"""Tools which both CherryPy and application developers may invoke.""" 
    22 
    3 import inspect 
    43import md5 
    54import mimetools 
     
    2524    """ 
    2625    newfunc = decorator(func) 
    27     for (k,v) in inspect.getmembers(func): 
    28         if not hasattr(newfunc, k): 
    29             setattr(newfunc, k, v
     26    for key in dir(func): 
     27        if not hasattr(newfunc, key): 
     28            setattr(newfunc, key, getattr(func, key)
    3029    return newfunc 
    3130 
     
    3736    """ 
    3837    obj_type = type(obj) 
    39     for (k,v) in inspect.getmembers(obj): 
    40         if hasattr(obj_type, k): # only deal with user-defined attributes 
    41             continue 
    42         if callable(v) and getattr(v, "exposed", False): 
    43             setattr(obj, k, decorate(v, decorator)) 
    44         decorateAll(v, decorator) 
     38    for key in dir(obj): 
     39        # only deal with user-defined attributes 
     40        if hasattr(obj_type, key): 
     41            value = getattr(obj, key) 
     42            if callable(value) and getattr(value, "exposed", False): 
     43                setattr(obj, key, decorate(value, decorator)) 
     44            decorateAll(value, decorator) 
    4545 
    4646 

Hosted by WebFaction

Log in as guest/cpguest to create tickets