On 7/7/05, Martijn Faassen <[EMAIL PROTECTED]> wrote:
> I noticed another possible oddness with zc.page. When I subclass
> form.PageEditForm, I normally get an 'edit' action provided with it, as
> the baseclass defines this.

The base class provides two things:

- the implementation of the edit action, and

- the "registration" of the edit action in self.actions.

> If I however add my own actions in the subclass, like this:
> @form.action("Another")
> def handle_another_action(self, action, data):
>      ...
> the 'edit' action just disappears from the action list.

Well, the entire set of actions is replaced.

> Not daunted by this, I tried the following to restore the edit action:
> @form.action("Edit")
> def handle_edit_action(self, action, data):
>      super(MyClass, self).handle_edit_action(action, data)
> The 'Edit' button now appears in the form. Unfortunately submitting it
> using this button results in:
> TypeError: 'Action' object is not callable


> Not giving up, I tried it another way, and placed this in the class,
> above the place where the extra action gets defined:
>      actions = form.Actions(
>          form.Action("Edit", success="handle_edit_action"),
>          )
> Unfortunately no luck either when I submit:
>    File "/home/faassen/working/doclib/py/zc/page/form.py", line 735, in
> __call__
>      self.update()
>    File "/home/faassen/working/doclib/py/zc/page/form.py", line 715, in
> update
>      result = action.success(data)
>    File "/home/faassen/working/doclib/py/zc/page/form.py", line 567, in
> success
>      return self.success_handler(self.form, self, data)
>    File "/home/faassen/working/doclib/py/zc/page/form.py", line 507, in
> <lambda>
>      callable = lambda form, action, data: getattr(form, f)(action, data)
> TypeError: 'Action' object is not callable
> Is this a bug?

That might be; I'll let Jim say for sure.

If you only want to add actions, what you can do in your view class is this:

    class MyForm(form.EditForm):

        actions = form.EditForm.actions[:]

        def handle_whatever(self, action, data):


Fred L. Drake, Jr.    <fdrake at gmail.com>
Zope Corporation
Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to