dabo Commit
Revision 3780
Date: 2007-12-09 21:45:39 -0800 (Sun, 09 Dec 2007)
Author: Nate
Trac: http://svn.dabodev.com/trac/dabo/changeset/3780
Changed:
U trunk/dabo/ui/uiwx/dEditor.py
Log:
I was using the dEditor widget in a program I was writing. I tested it on
Linux for the first time tonight and noticed two things:
- if I didn't have proper read permissions and called openFile, the
dEditor widget treated the file like it didn't exists and asked me to create a
new file.
- If I didn't have the proper write permissions and called saveFile,
the dEditor widget would just crash from an IO Error.
I fixed both of them. I also have checkChangesAndContinue return False (same
as if the user cancelled) if the save failed due to write permissions.
Diff:
Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py 2007-12-09 20:41:01 UTC (rev 3779)
+++ trunk/dabo/ui/uiwx/dEditor.py 2007-12-10 05:45:39 UTC (rev 3780)
@@ -1333,9 +1333,13 @@
fname = self.promptForSaveAs()
if fname is None:
# user canceled in the prompt: don't continue
- return None
+ return False
- open(fname, "wb").write(self.GetText().encode(self.Encoding))
+ try:
+ open(fname,
"wb").write(self.GetText().encode(self.Encoding))
+ except:
+ dabo.ui.stop("Could not save %s. Please check your
write permissions." % fname)
+ return False
# set self._fileName, in case it was changed with a Save As
self._fileName = fname
self._clearDocument(clearText=False)
@@ -1345,6 +1349,8 @@
app.setUserSetting("editor.fontface", self._fontFace)
# Save the bookmarks
self._saveBookmarks()
+
+ return True
def _saveBookmarks(self, evt=None):
@@ -1386,7 +1392,7 @@
ret = False
elif r == True:
# user wants changes saved.
- self.saveFile()
+ ret = self.saveFile()
else:
# user doesn't want changes saved.
pass
@@ -1426,6 +1432,9 @@
text = f.read().decode(self.Encoding)
f.close()
except:
+ if os.path.exists(fileSpec):
+ dabo.ui.stop("Could not open %s.
Please check that you have read permissions." % fileSpec)
+ return False
if dabo.ui.areYouSure("File '%s' does not
exist."
" Would you like to create it?"
% fileSpec):
text = ""
_______________________________________________
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]