[Zope3-dev] Re: Alternate schema types
Tres Seaver
tseaver at palladion.com
Tue Jul 12 11:50:20 EDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Gary Poster wrote:
> On Jul 12, 2005, at 11:01 AM, Tres Seaver wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> I would like to break the hard-wired assumption in the forms / widgets
>> machinery that all schemas must be interfaces with fields; in
>> particular, I would like to make the introspection of the fieldset from
>> a given schema pluggable.
>
> The use cases make sense to me.
>
> An observation is that the proposed implementation only works with
> zope.app.form and perpetuates some other assumptions within the
> zope.app.form.utility module--assumptions that we have found constraining.
>
> The zope.formlib package (http://svn.zope.org/zope.formlib/trunk/,
> formerly known as zc.page) already provides a more powerful abstraction
> in IFormFields. The abstraction is only helpful with the zope.formlib
> utilities, though (not zope.app.form.utlilty).
Would a similar indirection work there? E.g., instead of:
>>> from zope import interface, schema
>>> class IOrder(interface.Interface):
... identifier = schema.Int(title=u"Identifier", readonly=True)
... name = schema.TextLine(title=u"Name")
... min_size = schema.Float(title=u"Minimum size")
... max_size = schema.Float(title=u"Maximum size")
... now = schema.Datetime(title=u"Now", readonly=True)
>>> from zope.formlib import form
>>> class MyForm:
... form_fields = form.Fields(IOrder)
we could do:
>>> from zope import interface, schema
>>> class IOrder(interface.Interface):
... identifier = schema.Int(title=u"Identifier", readonly=True)
... name = schema.TextLine(title=u"Name")
... min_size = schema.Float(title=u"Minimum size")
... max_size = schema.Float(title=u"Maximum size")
... now = schema.Datetime(title=u"Now", readonly=True)
>>> from zope.formlib import IFormFields
>>> class MyForm:
... form_fields = IFormFields(IOrder)
and register zope.formlib.form.Fields as the "default" adapter factory
for IFormFields? (where IFormFields would be the 'IFormIntrospector'
I sketched)?
> A notable downside is that it is not an out-of-the-box fit for Zope
> 2.8/Five, since the package relies on Python 2.4. A Python 2.3 version
> probably would be easy enough, removing some of the Python 2.4 features.
Those are mostly decorator-based, right? In that case, aren't they
basically sugar?
Tres.
- --
===================================================================
Tres Seaver +1 202-558-7113 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFC0+a8+gerLs4ltQ4RAuGEAJ0XByKAgW+FNEI3Kj+Fw0wm1tWxDQCgqnxU
8feGwyZU9Jw/7YbxcxG1koU=
=Xb09
-----END PGP SIGNATURE-----
More information about the Zope3-dev
mailing list