Ticket #2535: manipulator_validators.diff
File manipulator_validators.diff, 1.5 KB (added by , 18 years ago) |
---|
-
Users/korpios/checkouts/django/trunk/django/db/models/fields/__init__.py
7 7 from django.utils.functional import curry 8 8 from django.utils.text import capfirst 9 9 from django.utils.translation import gettext, gettext_lazy 10 import datetime, os, time 10 import datetime, os, time, inspect 11 11 12 12 class NOT_PROVIDED: 13 13 pass … … 225 225 """ 226 226 field_objs, params = self.prepare_field_objs_and_params(manipulator, name_prefix) 227 227 228 # Curry validators that require the manipulator passed in. 229 for i, validator in enumerate(params['validator_list']): 230 assert callable(validator), "Validator not callable: %r" % validator 231 if inspect.isfunction(validator): 232 wrap = len(inspect.getargspec(validator)[0]) == 3 233 elif inspect.ismethod(validator): 234 wrap = len(inspect.getargspec(validator)[0]) == 4 235 else: 236 wrap = len(inspect.getargspec(validator.__call__)[0]) == 4 237 if wrap: 238 params['validator_list'][i] = curry(validator, manipulator) 239 228 240 # Add the "unique" validator(s). 229 241 for field_name_list in opts.unique_together: 230 242 if field_name_list[0] == self.name: