From 51ca5f4d5ffbe15601ee6a5ed41bd85c5f615b55 Mon Sep 17 00:00:00 2001 From: Antoine Durand-Gasselin Date: Tue, 29 Sep 2009 15:42:14 +0200 Subject: [PATCH] [lib/dialogwizard] typo darcs-hash:20090929134214-bd074-b24076612b84473fe9acaa70d26fc649399e0015.gz --- lib/dialogwizard/dialogwizard.py | 7 ++++--- lib/dialogwizard/wizard.py | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/dialogwizard/dialogwizard.py b/lib/dialogwizard/dialogwizard.py index 41e2cc77..e31d6bae 100755 --- a/lib/dialogwizard/dialogwizard.py +++ b/lib/dialogwizard/dialogwizard.py @@ -8,16 +8,17 @@ from wizard import Step, PreviousStep, EndScenario, TryAgain from itertools import izip -import dialog, time +import dialog, time, sys, commands def really_quit(dico): raise EndScenario("game over!", data = dico) def error_handler(exc): - dialog.Dialog().msgbox('Erreur:', exc.__repr__()) + sexc = (str(exc)) + dialog.Dialog().msgbox(sexc, title = 'Erreur :') raise TryAgain() -class DialogStepGenerator(): +class DialogStepGenerator: u"""This class defines a step, that will prompt the user for various fields.""" diff --git a/lib/dialogwizard/wizard.py b/lib/dialogwizard/wizard.py index bbc486f3..01032a3d 100755 --- a/lib/dialogwizard/wizard.py +++ b/lib/dialogwizard/wizard.py @@ -33,7 +33,7 @@ class Step: class Scenario: u"""This class allows us to define scenarios.""" - def __init__(self) + def __init__(self): u"""empty scenario, with an error handler (that takes an exception as argument)""" self.steps = None @@ -162,7 +162,18 @@ class Running: pass except Exception, e: - self.handle(e) + try: + self.handle(e) + + except PreviousStep: + if self.stack: + self.env, self.defaults, self.steps, self.stack = self.stack + else: + raise EndScenario("No previous step", self.env) + + except TryAgain: + # We can update defaults + pass else: # Should not be called