plone / plone/documentation

z3c.form widgetTemplate manual override example make no sense

Open
#893 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

31 needs: help 33 needs: docs 42 lvl: moderate 99 tag: Plone 6.x
Dominant language
Makefile
Stars
106
Forks
190
Avg merge
3d 2h
Merged PRs (30d)
1

Description

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 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open develop/plone/forms/z3c.form.rst and inspect the manual widgetTemplate override example and its imports. Check the example against the current z3c.form API, correct the non-working template reference and deprecated ViewPageTemplateFile import, and verify that the documentation example is valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.