Example #1
0
File: record.py Project: a25kk/stv2
        def _subfieldValidationLayer(self, subfield):
            """
            for the individual subfields
            """
            chainname = 'Validator_%s_%s' % (self.getName(), subfield)
            current_validators = self.subfield_validators.get(subfield, ())

            if type(current_validators) is DictType:
                raise NotImplementedError, 'Please use the new syntax with validation chains'
            elif IValidationChain.isImplementedBy(current_validators):
                validators = current_validators
            elif IValidator.isImplementedBy(current_validators):
                validators = ValidationChain(chainname, validators=current_validators)
            elif type(current_validators) in (TupleType, ListType, StringType):
                if len(current_validators):
                    # got a non empty list or string - create a chain
                    try:
                        validators = ValidationChain(chainname, validators=current_validators)
                    except (UnknowValidatorError, FalseValidatorError), msg:
                        log("WARNING: Disabling validation for %s/%s: %s" % (self.getName(), subfield, msg))
                        validators = ()
                else:
                    validators = ()
Example #2
0
 def test_validation_layer_from_id_field_from_base_schema_was_initialized(self):
     field = ATContentTypeSchema['id']
     self.assertTrue(IValidationChain.providedBy(field.validators))
Example #3
0
 def test_validation_layer_from_id_field_from_base_schema_was_initialized(
         self):
     field = ATContentTypeSchema['id']
     self.assertTrue(IValidationChain.providedBy(field.validators))
Example #4
0
 def test_validation_layer_from_id_field_from_base_schema_was_initialized(self):
     field = ATContentTypeSchema['id']
     self.failUnless(IValidationChain.isImplementedBy(field.validators))