CMF 2.0 ships with some view based forms. They use their own framework
and are explicitly labeled as experimental.
CMF 2.1 depends on Zope 2.10, so zope.formlib is now available. I
propose to replace the view based forms using zope.formlib.
This is the approach I propose:
The interfaces of classic CMF content objects are not suitable for
- Text fields are encoded strings while zope.formlib expects unicode.
- Datetime fields are Zope DateTime objects while zope.formlib expects
generic datetime objects.
- Tuples or lists are used for unordered collections while zope.formlib
expects Set fields.
- Different setter and getter methods are used while zope.formlib
I propose to add suitable schemas in the browser packages and to use
adapters to map the form schemas to the existing content interfaces.
I have a ProxyFieldProperty class (similar to zope.schema's
FieldProperty class) that does the necessary mapping. This is how it is
used for a CMFCalendar Event::
"""Adapter for IMutableEvent.
title = ProxyFieldProperty(IEventSchema['title'],
contact_name = ProxyFieldProperty(IEventSchema['contact_name'])
location = ProxyFieldProperty(IEventSchema['location'])
contact_email = ProxyFieldProperty(IEventSchema['contact_email'])
categories = ProxyFieldProperty(IEventSchema['categories'],
contact_phone = ProxyFieldProperty(IEventSchema['contact_phone'])
event_url = ProxyFieldProperty(IEventSchema['event_url'])
start_date = ProxyFieldProperty(IEventSchema['start_date'],
stop_date = ProxyFieldProperty(IEventSchema['stop_date'],
description = ProxyFieldProperty(IEventSchema['description'],
Maybe my ProxyFieldProperty implementation does too much magic at the
moment. I expect it has to evolve over time, adding a way to control the
If we have that adapter in place we can use zope.formlib in the generic
"""Edit view for IMutableEvent.
form_fields = form.FormFields(IEventSchema)
Some CMF specific base classes are needed for this. I propose to add
them in CMFDefault.formlib.
I have working code for IMutableEvent, IMutableFavorite and
IMutableLink. I can't promise to convert the other forms.
Any feedback is welcome.
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests