[Zope3-dev] interface/schema

Terry Hancock hancock at anansispaceworks.com
Sat Jun 19 02:30:04 EDT 2004


Hi all,
Okay, I've finally had a chance to start looking over
the interface/schema modules in ZopeX3-3.0.0b1.

Mostly great!  The documentation README.txt files are a
heck of a lot nicer -- my compliments to their authors.

I like the idea of the implements() method of declaring
interfaces better than the old method, and the ability
to use zope 3 interfaces alongside Zope 2 is going to be
a big help for me.

Reading the Schema README.txt file, I note the mention of
some controversy over whether schema and interface should
be merged. I think I've already said this, but I'll say it
again -- I think they should be.

The distinction between them seems entirely specious to me.

Python and Zope are quite friendly toward the use of
"callable objects" (i.e. other than functions and methods).
Examples in Zope include the DTMLFile() and SQL() objects
(in Zope 2 of course).  And this is a very useful tool,
in my experience.

Furthermore, I find myself having situations where I do
not want to directly subclass an object, but would rather
add an attribute to it which provides a desired interface
(this mostly occurs when I want to provide a common way
to provide add-on interfaces to a variety of objects written
by others with little risk of name collision).

And there are other cases where it's desireable to have such
"schema" qualities in an "interface".

I've had relatively little use for object-oriented databases
in my experience so far, so the use of a "schema" as a
"schema" is not so easy for me to find examples for.

However, since the general idea of OODB is to associate
"context aware" code with an object, it seems likely that
such a programmer will eventually want methods as schema
"fields".

So I think ultimately "schema" and "interface" should simply
be synonyms -- different applications for the same
technique. At least in Zope.

And also I want to point out that a promise made in the
"schema" README.txt has been broken:

"""
Dependencies
------------
 
The ``zope.schema`` package only depends on the ``zope.interface`` package.
"""

but if you isolate them and try it:

Python 2.3.4 (#2, May 29 2004, 03:31:27)
[GCC 3.3.3 (Debian 20040417)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from zope import schema
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.3/site-packages/zope/schema/__init__.py", line 18, in ?
    from zope.schema._field import Field, Container, Iterable, Orderable
  File "/usr/local/lib/python2.3/site-packages/zope/schema/_field.py", line 27, in ?
    from zope.schema.interfaces import IField
  File "/usr/local/lib/python2.3/site-packages/zope/schema/interfaces.py", line 20, in ?
    from zope.schema._bootstrapfields import Field, Text, TextLine, Bool, Int
  File "/usr/local/lib/python2.3/site-packages/zope/schema/_bootstrapfields.py", line 18, in ?
    from zope.schema._bootstrapinterfaces import StopValidation
  File "/usr/local/lib/python2.3/site-packages/zope/schema/_bootstrapinterfaces.py", line 20, in ?
    from zope.i18nmessageid import MessageIDFactory
ImportError: No module named i18nmessageid

So, we actually have another dependency there on i18nmessageid.
Presumeably this happened during the effort to provide the i18n
of schema that the README refers to.  I'm pretty sure this *is*
new, because I think I tried this with an earlier milestone
release and it worked.

Don't know how you want to fix that (maybe just alter the
README.txt to include the new dependency?).

I'm still learning how to actually use the schema/interface
modules, so I'm sure I'll have more to say later.

Cheers and thanks for all your effort,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com




More information about the Zope3-dev mailing list