Skip to content

Commit

Permalink
Removed comma splices in max_length DeprecationWarning and elsewhere …
Browse files Browse the repository at this point in the history
…in the module

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6872 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Dec 4, 2007
1 parent 0c8f8f2 commit 72a5c03
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions django/utils/maxlength.py
@@ -1,6 +1,6 @@
""" """
Utilities for providing backwards compatibility for the maxlength argument, Utilities for providing backwards compatibility for the maxlength argument,
which has been replaced by max_length, see ticket #2101. which has been replaced by max_length. See ticket #2101.
""" """


from warnings import warn from warnings import warn
Expand All @@ -15,25 +15,24 @@ def legacy_maxlength(max_length, maxlength):
""" """
Consolidates max_length and maxlength, providing backwards compatibilty Consolidates max_length and maxlength, providing backwards compatibilty
for the legacy "maxlength" argument. for the legacy "maxlength" argument.
If one of max_length or maxlength is given, then that value is returned. If one of max_length or maxlength is given, then that value is returned.
If both are given, a TypeError is raised. If both are given, a TypeError is raised. If maxlength is used at all, a
If maxlength is used at all, a deprecation warning is issued. deprecation warning is issued.
""" """
if maxlength is not None: if maxlength is not None:
warn("maxlength is deprecated, use max_length instead.", warn("maxlength is deprecated. Use max_length instead.", DeprecationWarning, stacklevel=3)
DeprecationWarning,
stacklevel=3)
if max_length is not None: if max_length is not None:
raise TypeError("field can not take both the max_length" raise TypeError("Field cannot take both the max_length argument and the legacy maxlength argument.")
" argument and the legacy maxlength argument.")
max_length = maxlength max_length = maxlength
return max_length return max_length


def remove_maxlength(func): def remove_maxlength(func):
""" """
A decorator to be used on a class's __init__ that provides backwards A decorator to be used on a class's __init__ that provides backwards
compatibilty for the legacy "maxlength" keyword argument, i.e. compatibilty for the legacy "maxlength" keyword argument, i.e.
name = models.CharField(maxlength=20) name = models.CharField(maxlength=20)
It does this by changing the passed "maxlength" keyword argument It does this by changing the passed "maxlength" keyword argument
(if it exists) into a "max_length" keyword argument. (if it exists) into a "max_length" keyword argument.
""" """
Expand All @@ -58,7 +57,6 @@ class LegacyMaxlength(type):
Metaclass for providing backwards compatibility support for the Metaclass for providing backwards compatibility support for the
"maxlength" keyword argument. "maxlength" keyword argument.
""" """

def __init__(cls, name, bases, attrs): def __init__(cls, name, bases, attrs):
super(LegacyMaxlength, cls).__init__(name, bases, attrs) super(LegacyMaxlength, cls).__init__(name, bases, attrs)
# Decorate the class's __init__ to remove any maxlength keyword. # Decorate the class's __init__ to remove any maxlength keyword.
Expand Down

0 comments on commit 72a5c03

Please sign in to comment.