daboide Commit
Revision 839
Date: 2007-04-24 12:34:58 -0700 (Tue, 24 Apr 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/daboide/changeset/839
Changed:
U trunk/ClassDesigner.py
U trunk/ClassDesignerFormMixin.py
Log:
Added some defensive code to alert the user when writing to the disk fails.
Ticket [1057].
Diff:
Modified: trunk/ClassDesigner.py
===================================================================
--- trunk/ClassDesigner.py 2007-04-24 18:42:05 UTC (rev 838)
+++ trunk/ClassDesigner.py 2007-04-24 19:34:58 UTC (rev 839)
@@ -1469,11 +1469,11 @@
def onSaveDesign(self, evt):
- self.currentForm.onSaveDesign(evt)
+ self.wrapSave(self.currentForm.onSaveDesign, evt)
def onSaveClassDesign(self, evt):
- self.currentForm.onSaveClassDesign(evt)
+ self.wrapSave(self.currentForm.onSaveClassDesign, evt)
def onRunDesign(self, evt):
@@ -1558,17 +1558,34 @@
dui.callAfter(frm.saveState)
+ def wrapSave(self, func, *args, **kwargs):
+ """Call the desired save method, and catch any error that is
raised,
+ displaying it to the user. If no error occurs, return True;
otherwise,
+ return False.
+ """
+ try:
+ func(*args, **kwargs)
+ return True
+ except IOError, e:
+ dabo.ui.stop(_("Save failed; reason: %s") % e)
+ return False
+
+
def onSaveRunnable(self, evt):
- self.currentForm.onSaveDesign(evt)
+ if not self.wrapSave(self.currentForm.onSaveDesign, evt)
+ return
nm = self.currentForm.getClassFile()
fpath, fname = os.path.split(nm)
code = self.miniAppTemplate() % fname
out = os.path.splitext(nm)[0] + ".py"
- open(out, "w").write(code)
- dui.info(_("You can run your form by running the file\n%s")
- % out, title=_("Runnable App Saved"))
+ try:
+ open(out, "w").write(code)
+ dui.info(_("You can run your form by running the
file\n%s")
+ % out, title=_("Runnable App Saved"))
+ except IOError, e:
+ dabo.ui.stop(_("Save failed; reason: %s") % e)
+
-
def onRevert(self, evt):
"""Re-load the current design, losing any changes."""
cf = self.currentForm
Modified: trunk/ClassDesignerFormMixin.py
===================================================================
--- trunk/ClassDesignerFormMixin.py 2007-04-24 18:42:05 UTC (rev 838)
+++ trunk/ClassDesignerFormMixin.py 2007-04-24 19:34:58 UTC (rev 839)
@@ -157,7 +157,7 @@
ret = False
elif saveIt is True:
# They want to save
- self.onSaveDesign(None)
+ ret =
self.Controller.wrapSave(self.onSaveDesign, None)
# Otherwise, they said 'No'
return ret
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]