[z3-five] Annotations

Andy Adiwidjaja mail at adiwidjaja.com
Fri Aug 20 10:27:23 MEST 2004


>> My remaining problem is that I don't like writing HTML forms by hand, or
>> writing validators ;-).  I want my IAnnotation-stored attributes - forms
>> and validation - to be handled by a framework.  I'm used to relying on
>> Archetypes, but zope3's schema stuff sounds like a better fit here.
>> 
>> What problems (if any) do you foresee in exposing a zope3 schema-driven
>> form in a plone/archetypes object's 'tab'?

There are no really problems. Widgets are working in Z2, as are
vocabularies. You just have to implement a rendering framework, as the
Edit & AddViews of Z3 are not working.

We have a very basic FormSchemaBox working in Z2:
   http://svn.unioncms.org/repos/ucms/uccore/trunk/ui/formschemabox.py

with even more basic layout managers (these have to be replaced soon)

This box is registered as a view on (*, Interface):
  <view
      type="zope.publisher.interfaces.browser.IBrowserRequest"
      for="* zope.interface.Interface"
      provides=".ui.interfaces.IFormSchemaBox"
      factory=".ui.formschemabox.FormSchemaBox"
      permission="zope2.Public"
      />

and then can be used and rendered (we save the schema on the object at
the moment):

    new = zapi.getMultiView((obj, obj.schema), obj.REQUEST, IFormSchemaBox )
    return new.render(obj, {})

>>  How would I expose such a form
>> (and it's validation) through the CMF/plone skins tool?

As said, you have make something that renders the form (our box) and
call it. If you want to use it from a PageTemplate, you could have a
renderer-python script, which does the mentioned operations on the
current context. Then you can call it from a PageTemplate:
here/obj/formrenderer.

Validation happens when saving. For this you need another view, which
sets up the widgets and saves the data on the object:

setUpWidgets(self, obj.schema, IInputWidget, prefix=obj.id)
#print getWidgetsData(self, obj.schema)
applyWidgetsChanges(self, obj.schema, target=co)

Ok, just our solution and just the status at the moment...

Regards,

Andy



More information about the z3-five mailing list