[Zope3-dev] Schema Field Names

Martijn Faassen faassen@vet.uu.nl
Mon, 15 Jul 2002 11:51:07 +0200


kapil thangavelu wrote:
> this isn't about the implementation code, its about the explicit vs. implicit 
> nature of the semantics of two different naming conventions, which will lead, 
> imo, to one or the other in code which uses that convention. 
> 
> iotw. if use of a field has nothing to do semantically with the use of a 
> python type, why are we naming them that way. why not make the field names 
> explicit? 

But I disagree entirely here; the use of a field has *everything*
to do semantically with the use of a Python type, so that is why they
should be named accordingly. Schema are intended to be used by *Python
programmers*. Various use cases in the wiki assume this:

Validate object according to schema

Given an object, make sure it conforms to a schema. If it fails, a validation error is raised. (does object or class conform to schema?)

Validate tuple/dictionary according to schema

Given tuple/dictionary (arguments of apply()?), make sure the values conform
to a schema.

Object always conforms to schema

An object claims it implements a schema, and automatically makes sure that all its fields conform to the fields defined in the schema at setting. (what about mutable fields?)

Construct form for factory

The developer provides a schema for arguments of a factory (such as a class constructor), so that the machinery can automatically create a form for the factory.

Method uses schema for its arguments

A more general case than above, any method can provide a schema to which its arguments should conform. This schema can be used to create a form or to validate arguments upon any call.

Typecheck ZODB according to schema definitions.

Similar to Grouch, recurse through an existing ZODB and make sure all its object conform to some schema description.

Support python datatypes in schemas

Schemas should be pythonic and support python built-in types (such as integer, string, tuple, dictionary, instances).

These use cases have been here since May now -- Stephan and I wrote
them initially.

There are other use cases which require mapping of these schema to other
typesystems, such as integrating with HTML Forms, SQL, XML RPC and XML Schema.
These in my minds are more like views, and we need a converter framework
for this.

> for some reason i picture a telephone call, trying to tell someone to use 
> 'int'. 
> 
> perhaps a vote is in order?

If the people who vote at least consider the design of this thing and
the use cases.. Doesn't using the long names increase confusion as to what
schema are about? You seem to think they are about something else; 
do think we should create our own field hierarchy specific to Zope 3, or
that we should use XML Schema, or something like that?

Regards,

Martijn