[Zope3-dev] schema initial documentation

Craeg K Strong cstrong@arielpartners.com
Wed, 01 May 2002 16:48:32 -0400


R. David Murray wrote:

>On Sun, 28 Apr 2002, Craeg K Strong wrote:
>  
>
>>in the sort of metamodeling issues you are discussing.   My question is
>>this: will the
>>metamodel be reified?  That is, will it be captured as actual code and
>>classes such that models
>>could be generated automatically from it?    This is Goodness for many
>>reasons
>>(which we can get into in case it is not obvious to everybody).
>>    
>>
>
>I guess it's not obvious to me, probably because I don't know a lot
>about modeling tools.  In my visualization (which may or may not
>be shared by Martijn and Jim), there will be "generic" views and
>components that can use Schemas to automatically generate display
>and edit forms, possibly using additional meta-data provided by
>companion objects defined at the same level of abstraction as
>the Schemas.  Does your requirement go beyond that kind of thing?
>  
>
I think I am a little confused.   I was looking at the XML-Schema 
specification
on w3.org and it includes lots of ways of specifying rules that could be
used for validation.  For example, you might define a regular expression 
that specifies
 what a valid string input field value should look like, or set a 
maximum for the number
of a certain sequence (e.g. no more than 100 items can be entered on a 
purchase order), etc.

I can imagine how one might generate an XML-Schema from a python class, 
properly
annotated with other metadata.  I can further imagine how an HTML form 
might be generated from the
XML-Schema.  As a matter of fact, isn't that what the w3.org X-Forms 
standard is all
about?  I believe you define an XML-Schema that defines the data types, 
constraints,
and validation rules, and then a mapping (using X-Forms UI language) 
that specifies
how the actual form GUI should look.

But what you are talking about is creating a new kind of Schema, 
implemented in Python.
I wonder-- are you going to going to end up replicating the work done in 
XML-Schema?
Or is the idea to put together something from which one could optionally 
_generate_
an XML-Schema, if one wished?  That way you could stay python-centric 
but have a nice integration path.
Either way, I would think you would want to examine the XML-Schema spec 
and define
a specification (aka meta model) of your own that is similar in 
semantics as much as makes sense.

The metamodel will define the things that can exist: for example, a 
Schema can have Features,
Features can either be Associations, Mutators or Accessors.  
A Factory is automatically generated for a Schema.
Mutators can define Validators..... etc. etc.   and then you would 
describe the class hierarchy
of Validators: primitives or types or classes.   StringValidators can 
define regular expressions..etc.

Then you could programmatically query the metamodel if you wanted.  For 
example, in
my business logic/python layer, I could find out what validation rules 
would be applied
if I were to enter a social security number.   This kind of capability 
is convenient for
a) multiple types of UIs:  wireless, web, Tkinter/fat client  or b) EAI 
-- interfacing with
legacy systems that contain old data that may or may not be compliant 
with today's business rules.

Sorry for the rambling email, but I have hopefully explained a bit more 
about the sort
of requirements I am thinking about.    Your thoughts?

--Craeg