Validators

by Alexander Limi last modified Nov 01, 2009 02:31 PM

Validators no longer function with old style zope 2 interfaces but need new zope 3 style interfaces.

Error you may get when starting your zope instance:

Products.validation.exceptions.FalseValidatorError:
<Products.PloneSoftwareCenter.validators.ProjectIdValidator instance at 0xa92082c>

This means that the specified validator is using old interfaces and is not working anymore. You need to remove this line:

    __implements__= (IValidator,) 

(IValidator might be called ivalidator in all lowercase, at least in this specific example) and replace it with this:

        implements(IValidator) 

Example changesets:

If you now use this code on Plone 3, this will fail:

TypeError: Error when calling the metaclass bases
    iteration over non-sequence

So if you want to avoid that and be compatible with Plone 3 and 4 at the same time, you can conditionally use either of the two lines, like in this changeset.