Changeset 6955 for django/branches/newforms-admin/django/utils/maxlength.py
- Timestamp:
- 12/18/07 23:20:55 (1 year ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/django/utils/maxlength.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-6863 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-6952
django/branches/newforms-admin/django/utils/maxlength.py
r6864 r6955 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)
