Comment 1 for bug 236897

Revision history for this message
Philipp von Weitershausen (philikon) wrote : Re: [Bug 236897] [NEW] grok.Form subclasses expect an actions attribute when rendering

On 2 Jun 2008, at 22:14 , Dan Fairs wrote:
> (app.py)
> from zope.interface import Interface
> from zope.schema import TextLine
> import grok
>
> class IDummyForm(Interface):
> name = TextLine(title=u'name')
>
> class Content(grok.Application, grok.Container):
> grok.implements(IDummyForm)
>
>
> class DummyForm(grok.Form):
> grok.context(Content)
> form_fields = [] # or grok.AutoFields(Content)
>
> Visiting the /dummyform URL in the browser gives a traceback as
> follows:
>
> 2008-06-02T21:10:08 ERROR SiteError http://localhost:8080/foo/
> dummyform
> Traceback (most recent call last):
> ...
> AttributeError: 'DummyForm' object has no attribute 'actions'
>
> While forms with buttons are the common case, it's not hard to
> imagine a
> situation where a form might not have any buttons (perhaps the form is
> processed by some client-side javascript).
>
> It should be possible to have forms without buttons (actions).

You can simply add the 'actions' attribute to the form class to avoid
the exception:

class DummyForm(grok.Form):
    ...
    actions = []