diff options
Diffstat (limited to 'cherrypy')
| -rw-r--r-- | cherrypy/_cperror.py | 3 | ||||
| -rw-r--r-- | cherrypy/_helper.py | 31 |
2 files changed, 32 insertions, 2 deletions
diff --git a/cherrypy/_cperror.py b/cherrypy/_cperror.py index ab1cc70f..1e6214c0 100644 --- a/cherrypy/_cperror.py +++ b/cherrypy/_cperror.py @@ -125,12 +125,11 @@ from xml.sax import saxutils import six from six.moves import urllib -from jaraco.classes.properties import classproperty - import cherrypy from cherrypy._cpcompat import escape_html from cherrypy._cpcompat import text_or_bytes, ntob from cherrypy._cpcompat import tonative +from cherrypy._helper import classproperty from cherrypy.lib import httputil as _httputil diff --git a/cherrypy/_helper.py b/cherrypy/_helper.py index 505c4bc9..a0ab68fe 100644 --- a/cherrypy/_helper.py +++ b/cherrypy/_helper.py @@ -308,3 +308,34 @@ def normalize_path(path): newpath = '/' + newpath return newpath + + +#### +# Inlined from jaraco.classes 1.4.3 +# Ref #1673 +class _ClassPropertyDescriptor(object): + """Descript for read-only class-based property. + + Turns a classmethod-decorated func into a read-only property of that class + type (means the value cannot be set). + """ + + def __init__(self, fget, fset=None): + """Instantiated by ``_helper.classproperty``.""" + self.fget = fget + self.fset = fset + + def __get__(self, obj, klass=None): + """Return property value.""" + if klass is None: + klass = type(obj) + return self.fget.__get__(obj, klass)() + + +def classproperty(func): + """Decorator like classmethod to implement a static class property.""" + if not isinstance(func, (classmethod, staticmethod)): + func = classmethod(func) + + return _ClassPropertyDescriptor(func) +#### |
