dabo Commit
Revision 4339
Date: 2008-08-02 17:21:30 -0700 (Sat, 02 Aug 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4339

Changed:
U   trunk/dabo/ui/uiwx/dEditor.py

Log:
Added code to prevent saving a file that has been modified on disk since it was 
opened in the editor.


Diff:
Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py       2008-08-02 23:57:01 UTC (rev 4338)
+++ trunk/dabo/ui/uiwx/dEditor.py       2008-08-03 00:21:30 UTC (rev 4339)
@@ -1402,7 +1402,12 @@
                        if fname is None:
                                # 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:
                        open(fname, 
"wb").write(self.GetText().encode(self.Encoding))
                except OSError:
@@ -1410,6 +1415,7 @@
                        return False
                # set self._fileName, in case it was changed with a Save As
                self._fileName = fname
+               self._fileModTime = os.stat(fname).st_mtime
                self._clearDocument(clearText=False)
                # Save the appearance settings
                app = self.Application
@@ -1513,6 +1519,7 @@
                                else:
                                        return False
                        self._fileName = fileSpec
+                       self._fileModTime = os.stat(fileSpec).st_mtime
                        pth, fname = os.path.split(fileSpec)
                        fext = os.path.splitext(fname)[1]
                        self.Language = fileFormatsDic.get(fext, self.Language)




_______________________________________________
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/[EMAIL PROTECTED]

Reply via email to