[Zope3-dev] Z3 schemas and validation?

Anthony Baxter anthony at interlink.com.au
Mon Sep 8 20:15:18 EDT 2003


I'm trying to use the zope3 zope.schemas package outside zope3, 
but I've hit a pretty basic problem - how do I actually validate
the object conforms to the schema? The README.txt in the schema
package refers to a validateMapping function that no longer exists.

Is it a matter of something like (assuming the objects from
src/zope/schema/README.txt)

for name in IContact.names():
    IContact.get(name).validate(someone.__dict__[name])

Shouldn't this functionality be provided in some way, that's
less ugly for the programmer?

On a similar note, it appears that Interface.namesAndDescriptions is
misnamed, and/or the doc string is wrong:

    def namesAndDescriptions(all=False):
        """Get the interface attribute names and descriptions

        Return a sequence of the names and descriptions of the
        attributes, including methods, as name-value pairs, included
        in the interface definition.

The implementation, however, returns the names and the objects, not
the 'descriptions'

      return self.__attrs.items()

and looking at the test code, nothing ever checks the second value
is "correct".

Anthony



More information about the Zope3-dev mailing list