Changeset 1142
- Timestamp:
- 06/12/06 12:51:53
- Files:
-
- trunk/cherrypy/__init__.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r1141 r1142 155 155 non-standard attributes (like exposed) to the newly decorated function. 156 156 """ 157 import inspect158 157 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)) 162 161 return newfunc 163 162 … … 168 167 into these. This function modifies obj; there is no return value. 169 168 """ 170 import inspect171 169 obj_type = type(obj) 172 for (k,v) in inspect.getmembers(obj):173 if hasattr(obj_type, k ): # only deal with user-defined attributes170 for key in dir(obj): 171 if hasattr(obj_type, key): # only deal with user-defined attributes 174 172 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) 178 177 179 178

