So, thanks to Carsten, I have the following patterns working:

To override the templates for all occurrences of a widget class in a
given view:

     <z3c:widgetTemplate
         mode="display"
         widget="widget.package.interfaces.IWidget"
         layer="z3c.form.interfaces.IFormLayer"
         view="my.package.interfaces.ISomeView"
         template="path/to/template.pt"
         />

and, of course, "widget" may be the default widget or one you've
specified in the page form via:

    form.fields['myField'].widgetFactory = ...

but to override the template for only one occurrence of a widget in a
form, after the widget initialization (ie, in your update() method,
after doing "super().update()", use:

    from zope.interface import alsoProvides
    from my.package.interfaces import ISomeWidget
    alsoProvides(form.widgets['myField'], ISomeWidget)

and in the ZCML

     <z3c:widgetTemplate
         mode="display"
         widget="my.package.interfaces.ISomeWidget"
         layer="z3c.form.interfaces.IFormLayer"
         view="my.package.interfaces.ISomeView"
         template="path/to/template.pt"
         />

Thanks, Carsten
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to