diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-06-05 15:49:49 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-06-05 15:49:49 -0400 |
commit | f77bef63b18748e2bbbd66543f8fc06fa6d1c7b3 (patch) | |
tree | 084b502717dc100d0dc1c2d47e926ab20a54fa96 /cherrypy/_helper.py | |
parent | e19d2e6a562f6ba6bec5cff9d2fae09b958ad4ff (diff) | |
download | cherrypy-git-f77bef63b18748e2bbbd66543f8fc06fa6d1c7b3.tar.gz |
Add support for decorating classes as well as functions and methods
Diffstat (limited to 'cherrypy/_helper.py')
-rw-r--r-- | cherrypy/_helper.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cherrypy/_helper.py b/cherrypy/_helper.py index e5c893d0..56bc1a25 100644 --- a/cherrypy/_helper.py +++ b/cherrypy/_helper.py @@ -3,14 +3,14 @@ Helper functions for CP apps """ from cherrypy._cpcompat import urljoin as _urljoin, urlencode as _urlencode -from cherrypy._cpcompat import basestring +from cherrypy._cpcompat import basestring, py3k import cherrypy def expose(func=None, alias=None): """ - Expose the function, optionally providing an alias or set of aliases. + Expose the function or class, optionally providing an alias or set of aliases. """ def expose_(func): func.exposed = True @@ -24,7 +24,10 @@ def expose(func=None, alias=None): import sys import types - decoratable_types = types.FunctionType, types.MethodType + decoratable_types = types.FunctionType, types.MethodType, type, + if not py3k: + # Old-style classes are type types.ClassType. + decoratable_types += types.ClassType, if isinstance(func, decoratable_types): if alias is None: # @expose |