documentation icon indicating copy to clipboard operation
documentation copied to clipboard

z3c.form widgetTemplate manual override example make no sense

Open keul opened this issue 8 years ago • 1 comments

If you look at https://github.com/plone/documentation/blob/cf62b0a919c639592e7b59c781148e8ac2d0ca0f/develop/plone/forms/z3c.form.rst there's a manual override example for not using z3c:widgetTemplate.

This the code:

class HeaderFileWidget(NamedFileWidget):
    """ Subclass widget a use a custom template """

    display_template = ViewPageTemplateFile("header_file_display.pt")

    def render(self):
        """See z3c.form.interfaces.IWidget."""

        if self.mode == DISPLAY_MODE:
            # Enforce template and do not query it from the widget template factory
            template = self.display_template

        return NamedFileWidget.render(self)

The example is not working as template is a local var not assigned to anything. Maybe it's self.template?

Also (minor) some import at the top are deprecated/not working anymore:

- from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+ from zope.browserpage.viewpagetemplatefile import ViewPageTemplateFile 

keul avatar Jun 23 '17 10:06 keul

@keul thanks for noticing and taking the time to report it!

Do you have the extra time to prepare a pull request with the changes that you outlined above?

gforcada avatar Jun 27 '17 19:06 gforcada