[Zope-CVS] CVS: Products/ExternalEditor - CHANGES.txt:1.10 zopeedit.py:1.11
Casey Duncan
casey@zope.com
Mon, 10 Jun 2002 15:25:25 -0400
Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv4129
Modified Files:
CHANGES.txt zopeedit.py
Log Message:
Improved behavior on save if lock failed
=== Products/ExternalEditor/CHANGES.txt 1.9 => 1.10 ===
+ - Improved behavior when saving after lock attempts fail.
+
- Now works on Windows (applause) using Pythonwin. Much overall
refactoring to abstract process control. Thanks to Oliver Deckmyn and
Gabriel Genellina for testing, patches and suggestions.
=== Products/ExternalEditor/zopeedit.py 1.10 => 1.11 ===
"""Launch external editor"""
save_interval = float(self.options.get('save_interval'))
- use_locks = int(self.options.get('use_locks'))
+ use_locks = int(self.options.get('use_locks', 0))
launch_success = 0
last_mtime = path.getmtime(self.content_file)
command = '%s %s' % (self.getEditorCommand(), self.content_file)
@@ -221,6 +221,15 @@
def putChanges(self):
"""Save changes to the file back to Zope"""
+ if int(self.options.get('use_locks', 0)) and \
+ not hasattr(self, 'lock_token'):
+ # We failed to get a lock initially, so try again before saving
+ if not self.lock():
+ # Confirm save without lock
+ if not askYesNo('Could not acquire lock. '
+ 'Attempt to save to Zope anyway?'):
+ return 0
+
f = open(self.content_file, 'rb')
body = f.read()
f.close()