On 2007-08-20 14:59:52 +0200, "Fred Drake" <[EMAIL PROTECTED]> said:

On 8/20/07, Christian Zagrodnick <[EMAIL PROTECTED]> 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]


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.

Yes, I like the idea.

Will add it with the exception as time comes by.

Christian Zagrodnick

gocept gmbh & co. kg  ·  forsterstrasse 29 · 06112 halle/saale
www.gocept.com · fon. +49 345 12298894 · fax. +49 345 12298891

Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to