On 29 mai, 14:38, Jean Cavallo <[email protected]> wrote:
> > Ok I upgraded to v2.4 and did what you proposed.
> > But i get the same problem as in v2.2 which is that
> > self.raise_user_error causes stops execution and the wizard window is
> > closed on the client... In fact my problem boils down to: how can I
> > display a user message without stoping execution ?
>
> Well, I had this particular problem and had to use a workaround as it is
> not yet possible to do exactly that.
>
> The best way I came up with is what I suggested earlier :
>
> You use a button that points to a StateTransition in which you do your
> validation, then raise_user_error the message you want.
>
> When doing that, the client will stay on the latest displayed view, so it
> should be what need.
>
> There is no way yet to display a message with the possibility to resume
> execution, as the code you might want to resume is on the server when
> the message displaying is on the client.
>
> raise_user_warning sort of emulates that : when used, if the user clicks on
> 'Continue', it will re-execute the previously executed code then skip the
> warning. So even though it looks like execution did not stop, it did.
>
> You could talk to the tryton heads for more info, and do not hesitate to ask
> if my solution is not clear enough.
>
> Jean CAVALLO
Nice ! it works exactly with the perfect user experience !
In Tryton v2.2 the wizard window was closing when calling
self.raise_user_error.
In v2.4 it stays open so it is worth upgrading for anyone who needs to
do form validation
To clarify for others, I was confused by your looping to the
create_state. Maybe a more practical use case is:
class A(Wizard):
start_state = StateView(...)
action_state = StateTransition()
def transition_action_state(self, session):
# validate form data using session.start_state
if errors:
self.raise_user_error(errors)
# else do stuff with the valid data
--
[email protected] mailing list