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

Changeset 1142

Show
Ignore:
Timestamp:
06/12/06 12:51:53
Author:
fumanchu
Message:

Removed inspect import in cherrypy.decorate, decorateAll.

Files:

Legend:

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

    r1141 r1142  
    155155    non-standard attributes (like exposed) to the newly decorated function. 
    156156    """ 
    157     import inspect 
    158157    newfunc = decorator(func) 
    159     for (k,v) in inspect.getmembers(func): 
    160         if not hasattr(newfunc, k): 
    161             setattr(newfunc, k, v
     158    for key in dir(func): 
     159        if not hasattr(newfunc, key): 
     160            setattr(newfunc, key, getattr(func, key)
    162161    return newfunc 
    163162 
     
    168167    into these. This function modifies obj; there is no return value. 
    169168    """ 
    170     import inspect 
    171169    obj_type = type(obj) 
    172     for (k,v) in inspect.getmembers(obj): 
    173         if hasattr(obj_type, k): # only deal with user-defined attributes 
     170    for key in dir(obj): 
     171        if hasattr(obj_type, key): # only deal with user-defined attributes 
    174172            continue 
    175         if callable(v) and getattr(v, "exposed", False): 
    176             setattr(obj, k, decorate(v, decorator)) 
    177         decorateAll(v, decorator) 
     173        value = getattr(obj, key) 
     174        if callable(value) and getattr(value, "exposed", False): 
     175            setattr(obj, key, decorate(value, decorator)) 
     176        decorateAll(value, decorator) 
    178177 
    179178 

Hosted by WebFaction

Log in as guest/cpguest to create tickets