Changeset 6872
- Timestamp:
- 12/03/07 23:56:30 (7 months ago)
- Files:
-
- django/trunk/django/utils/maxlength.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/utils/maxlength.py
r6825 r6872 1 1 """ 2 2 Utilities for providing backwards compatibility for the maxlength argument, 3 which has been replaced by max_length , see ticket #2101.3 which has been replaced by max_length. See ticket #2101. 4 4 """ 5 5 … … 16 16 Consolidates max_length and maxlength, providing backwards compatibilty 17 17 for the legacy "maxlength" argument. 18 18 19 If one of max_length or maxlength is given, then that value is returned. 19 If both are given, a TypeError is raised. 20 If maxlength is used at all, adeprecation warning is issued.20 If both are given, a TypeError is raised. If maxlength is used at all, a 21 deprecation warning is issued. 21 22 """ 22 23 if maxlength is not None: 23 warn("maxlength is deprecated, use max_length instead.", 24 DeprecationWarning, 25 stacklevel=3) 24 warn("maxlength is deprecated. Use max_length instead.", DeprecationWarning, stacklevel=3) 26 25 if max_length is not None: 27 raise TypeError("field can not take both the max_length" 28 " argument and the legacy maxlength argument.") 26 raise TypeError("Field cannot take both the max_length argument and the legacy maxlength argument.") 29 27 max_length = maxlength 30 28 return max_length … … 34 32 A decorator to be used on a class's __init__ that provides backwards 35 33 compatibilty for the legacy "maxlength" keyword argument, i.e. 36 name = models.CharField(maxlength=20) 34 name = models.CharField(maxlength=20) 35 37 36 It does this by changing the passed "maxlength" keyword argument 38 37 (if it exists) into a "max_length" keyword argument. … … 59 58 "maxlength" keyword argument. 60 59 """ 61 62 60 def __init__(cls, name, bases, attrs): 63 61 super(LegacyMaxlength, cls).__init__(name, bases, attrs)
