Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use `classmethod` as a decorator.

  • Loading branch information...
commit 4cfe6ba6a3d16a16f0561f2f3c5b56d117f8a60d 1 parent 73b3c25
xuxiang dlutxx authored charettes committed
2  django/core/files/uploadedfile.py
View
@@ -117,6 +117,7 @@ def __init__(self, name, content, content_type='text/plain'):
super(SimpleUploadedFile, self).__init__(BytesIO(content), None, name,
content_type, len(content), None, None)
+ @classmethod
def from_dict(cls, file_dict):
"""
Creates a SimpleUploadedFile object from
@@ -128,4 +129,3 @@ def from_dict(cls, file_dict):
return cls(file_dict['filename'],
file_dict['content'],
file_dict.get('content-type', 'text/plain'))
- from_dict = classmethod(from_dict)
2  django/dispatch/saferef.py
View
@@ -135,6 +135,7 @@ def remove(weak, self=self):
self.selfName = str(target.__self__)
self.funcName = str(target.__func__.__name__)
+ @classmethod
def calculateKey(cls, target):
"""Calculate the reference key for this reference
@@ -142,7 +143,6 @@ def calculateKey(cls, target):
target object and the target function respectively.
"""
return (id(target.__self__), id(target.__func__))
- calculateKey = classmethod(calculateKey)
def __str__(self):
"""Give a friendly representation of the object"""
4 django/utils/functional.py
View
@@ -93,6 +93,7 @@ def __reduce__(self):
(func, self.__args, self.__kw) + resultclasses
)
+ @classmethod
def __prepare_class__(cls):
cls.__dispatch = {}
for resultclass in resultclasses:
@@ -119,8 +120,8 @@ def __prepare_class__(cls):
cls.__bytes__ = cls.__bytes_cast
else:
cls.__str__ = cls.__bytes_cast
- __prepare_class__ = classmethod(__prepare_class__)
+ @classmethod
def __promise__(cls, klass, funcname, method):
# Builds a wrapper around some magic method and registers that
# magic method for the given type and method name.
@@ -137,7 +138,6 @@ def __wrapper__(self, *args, **kw):
cls.__dispatch[klass] = {}
cls.__dispatch[klass][funcname] = method
return __wrapper__
- __promise__ = classmethod(__promise__)
def __text_cast(self):
return func(*self.__args, **self.__kw)
2  django/utils/tree.py
View
@@ -27,6 +27,7 @@ def __init__(self, children=None, connector=None, negated=False):
# We need this because of django.db.models.query_utils.Q. Q. __init__() is
# problematic, but it is a natural Node subclass in all other respects.
+ @classmethod
def _new_instance(cls, children=None, connector=None, negated=False):
"""
This is called to create a new instance of this class when we need new
@@ -39,7 +40,6 @@ def _new_instance(cls, children=None, connector=None, negated=False):
obj = Node(children, connector, negated)
obj.__class__ = cls
return obj
- _new_instance = classmethod(_new_instance)
def __str__(self):
if self.negated:
Please sign in to comment.
Something went wrong with that request. Please try again.