durusmail: quixote-users: Patch: make overriding form component class easier
Patch: make overriding form component class easier
2003-11-23
Patch: make overriding form component class easier
2003-11-23
Patch: make overriding form component class easier
Patch: make overriding form component class easier
Michael Watkins
2003-11-23
On Sun, 2003-11-23 at 08:08, Greg Ward wrote:
> The FormComponent abstraction in quixote.form2 is nice, but it's hard to
> specify a default component class without subclassing Form and setting
> WIDGET_ROW_CLASS.  Come to think of it, COMPONENT_CLASS would be a
> better name than WIDGET_ROW_CLASS.
>
> Here's a patch.  Suggested checkin comment:
>
> """
> Rename Form.WIDGET_ROW_CLASS to COMPONENT_CLASS, since that'
> what it really is.  Make it an instance attribute as well as a
> class attribute, so it can be overridden at form construction
> time.
> """

+1 - this (almost) removes the need for me to subclass form now. I
already have two WidgetRow subclasses - one vertically and one
horizontally aligned, and had subclassed Form in much the same way as
suggested rather than create two or more Form classes.

The (almost) refers to the following (form2) Form methods which I am
currently overriding:

    def _render_start(self):
        r = TemplateIO(html=True)
        r += htmltag('form', name=self.name, method=self.method,
                     enctype=self.enctype, action=self.action_url)
        if self.legend is not None:
            r += htmltext('\n
\n%s\n') % self.legend r += self._render_hidden_widgets() return r.getvalue() def _render_finish(self): r = TemplateIO(html=True) if self.legend is not None: r += htmltext('\n
\n') r += htmltext('') r += self._render_javascript() return r.getvalue() > Of course, the renaming will break all existing code that uses > quixote.form2, but better now than later, eh? Agreement from me.. -- Mike Watkins mw@mikewatkins.net In the land of the dark, the Ship of the Sun is driven by the Grateful Dead. -- Egyptian Book of the Dead
reply