Re: [Zope3-Users] Multiple actions per button in formlib forms?

2006-09-15 Thread Bjorn Tillenius
On Thu, Sep 14, 2006 at 02:34:59PM +0200, Stefan Fink wrote:
 Hi list,
 
 how is it possible to add multiple actions per button to formlib forms?
 Actually I'm trying to create a button which:
  - applies all changes made in the form
  - takes the user back to the container view
 
 
 class GeneralEditForm(formlib.form.EditForm):
 
 ...
 
 # this does not work
 @formlib.form.action(u'ApplyClose')
 def handle_applyAndClose(self, action, data):
  apply form changes and close form.
 self.handle_edit_action(action, data)

You didn't include how you define handle_edit_action, but I assume you
use @formlib.form.action here as well:

@formlib.form.action(u'Edit')
def handle_edit_action(self, action, data):
...

What this code does is to create a new Action object, having the
handle_edit_action method as its success method. This action will be
added to self.actions, but more importantly, this action will also be
assigned to self.handle_edit_action. So in your handle_applyAndClose
method above, self.handle_edit_action isn't a method, it's an Action
object. (c.f the way @property works). So in order to call your edit
action you need to do:

self.handle_edit_action.sucess(data)


Regards,

Bjorn
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Multiple actions per button in formlib forms?

2006-09-14 Thread Martijn Pieters

On 9/14/06, Stefan Fink [EMAIL PROTECTED] wrote:

how is it possible to add multiple actions per button to formlib forms?
Actually I'm trying to create a button which:
 - applies all changes made in the form
 - takes the user back to the container view


Just call the second action method from the first? formlib actions
call one method, but nothing stops you from calling another method
form the first. It's what I do all the time.

--
Martijn Pieters
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Multiple actions per button in formlib forms?

2006-09-14 Thread Martijn Pieters

On 9/14/06, Stefan Fink [EMAIL PROTECTED] wrote:

That's what I'm trying to do. The problem is, that when calling
self.handle_edit_action(action, data), which is part of formlib, the
following error is raised:

Error object: 'Action' object is not callable


First of all, you need to provide complete tracebacks. Such an error
is next to useless.


Sorry, forgot to mention that before. Any ideas how to get things work?


No idea what you pass into that method as 'data'. The action attr is
ignored by that method.

--
Martijn Pieters
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users