dabo Commit
Revision 4399
Date: 2008-08-11 15:13:05 -0700 (Mon, 11 Aug 2008)
Author: Nate
Trac: http://svn.dabodev.com/trac/dabo/changeset/4399
Changed:
U trunk/dabo/ui/uiwx/dEditor.py
Log:
The check for file update additions that were introduced caused errors to be
thrown when openFile would be called, the user would select a file that didn't
exist, and they would select to create the file from the dialog. The filepath
would be stored like we did an actual save but no save occurred so when the
editor would check for modifications it would fail. This fixes the problem.
Also, a change in behavior that comes out of this is that new files whose
Values were "" can now be saved.
Diff:
Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py 2008-08-11 18:22:16 UTC (rev 4398)
+++ trunk/dabo/ui/uiwx/dEditor.py 2008-08-11 22:13:05 UTC (rev 4399)
@@ -1382,7 +1382,7 @@
def saveFile(self, fname=None):
- if not self.isChanged():
+ if not self.isChanged() and self._fileName:
# Nothing changed
return
if self._curdir:
@@ -1392,7 +1392,6 @@
fname = self._fileName
except AttributeError:
fname = self._newFileName
-
if not fname or (fname == self._newFileName):
# We are being asked to save a new file that doesn't
exist on disk yet.
fname = self.promptForSaveAs()
@@ -1400,11 +1399,14 @@
# user canceled in the prompt: don't continue
return False
else:
- fModTime = os.stat(fname).st_mtime
- if fModTime > self._fileModTime:
- if not dabo.ui.areYouSure(_("""The file has
been modified on the disk since you opened it.
-Do you want to overwrite it?"""), _("File Conflict"), defaultNo=True,
cancelButton=False):
- return
+ try:
+ fModTime = os.stat(fname).st_mtime
+ if fModTime > self._fileModTime:
+ if not dabo.ui.areYouSure(_("""The file
has been modified on the disk since you opened it.
+ Do you want to overwrite it?"""), _("File Conflict"), defaultNo=True,
cancelButton=False):
+ return
+ except StandardError:
+ pass
try:
open(fname,
"wb").write(self.GetText().encode(self.Encoding))
except OSError:
@@ -1532,6 +1534,7 @@
if dabo.ui.areYouSure("File '%s' does not
exist."
" Would you like to create it?"
% fileSpec):
text = ""
+ self.saveFile(fileSpec)
else:
return False
self._fileName = fileSpec
_______________________________________________
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/%(messageid)s