[Zope3-dev] Re: Add function for schema validation in zope.schema

Tres Seaver tseaver at palladion.com
Mon Aug 20 10:04:05 EDT 2007

Hash: SHA1

Fred Drake wrote:
> On 8/20/07, Christian Zagrodnick <cz at gocept.com> wrote:
>> I think we should add a function to validate a given schema on a given
>> class. This should include constraints and invariants:
> I do presume you mean object, rather than class, as your example implies.
>> validateSchema(IMySchema, myobject)  [or alike]
> +1
>> I'm not sure about return values or exceptions. There are different use cases:
>> 1. Is the object valid? -> True/False
>> 2. What's wrong with the object -> {attribute/field-name: what's
>> wrong}, what's wrong with invariants.
> There should probably be a specific exception that's defined for this
> purpose, and it could directly support the mapping interface to allow
> detailed information to be extracted.  I suspect a common use would be
> to simply verify the object and raise the exception in the invalid
> case, denying whatever operation was being attempted.
> This also suggests that there's no interesting return value; either
> the exception is raised or it isn't.  Code that wants to introspect
> the exception can catch that and act accordingly.

- -1.  Detecting the schema violation is "mechanism",  raising an
exception is "policy";  they shouldn't be mixed here.  Let the caller
raise an exception if that is appropriate

- --
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the Zope3-dev mailing list