Refs #23919 -- Removed usage of django.utils.decorators.ContextDecorator.

This commit is contained in:
Chillar Anand 2017-01-19 21:58:30 +05:30 committed by Tim Graham
parent 4c5ed3e683
commit 41e0033caf
4 changed files with 6 additions and 23 deletions

View file

@ -1,10 +1,7 @@
"Functions that help with dynamically creating decorators for views."
try:
from contextlib import ContextDecorator
except ImportError:
ContextDecorator = None
# For backwards compatibility in Django 2.0.
from contextlib import ContextDecorator # noqa
from functools import WRAPPER_ASSIGNMENTS, update_wrapper, wraps
@ -166,21 +163,6 @@ def make_middleware_decorator(middleware_class):
return _make_decorator
if ContextDecorator is None:
# ContextDecorator was introduced in Python 3.2
# See https://docs.python.org/3/library/contextlib.html#contextlib.ContextDecorator
class ContextDecorator:
"""
A base class that enables a context manager to also be used as a decorator.
"""
def __call__(self, func):
@wraps(func, assigned=available_attrs(func))
def inner(*args, **kwargs):
with self:
return func(*args, **kwargs)
return inner
class classproperty:
def __init__(self, method=None):
self.fget = method