[Zope-CVS] CVS: Products/ExternalEditor - CHANGES.txt:1.31 zopeedit.py:1.36
Casey Duncan
casey@zope.com
Sat, 31 Aug 2002 00:17:37 -0400
Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv20524
Modified Files:
CHANGES.txt zopeedit.py
Log Message:
Added win32 editor plugin support
Added HomeSite editor plugin
=== Products/ExternalEditor/CHANGES.txt 1.30 => 1.31 ===
--- Products/ExternalEditor/CHANGES.txt:1.30 Tue Aug 20 23:39:38 2002
+++ Products/ExternalEditor/CHANGES.txt Sat Aug 31 00:17:32 2002
@@ -1,5 +1,9 @@
External Editor Change Log
+ - Added HomeSite plugin (win32)
+
+ - Added win32 editor plugin support for the helper application.
+
8/19/02 - 0.5 Release
- Added patch for Zope find template so that you can use external editor
=== Products/ExternalEditor/zopeedit.py 1.35 => 1.36 ===
--- Products/ExternalEditor/zopeedit.py:1.35 Thu Aug 8 10:43:58 2002
+++ Products/ExternalEditor/zopeedit.py Sat Aug 31 00:17:32 2002
@@ -19,7 +19,7 @@
__version__ = '0.5'
-import sys, os
+import sys, os, re
import traceback
from tempfile import mktemp
from ConfigParser import ConfigParser
@@ -314,17 +314,41 @@
launch_success = 0
last_mtime = os.path.getmtime(self.content_file)
command = self.getEditorCommand()
-
+
+ # Extract the executable name from the command
if win32:
- file_insert = '%1'
- else:
- file_insert = '$1'
-
- if command.find(file_insert) > -1:
- command = command.replace(file_insert, self.content_file)
+ if command.find('\\') != -1:
+ bin = re.search(r'\\([^\.\\]+)\.exe', command.lower())
+ if bin is not None:
+ bin = bin.group(1)
+ else:
+ bin = command.strip()
else:
- command = '%s %s' % (command, self.content_file)
- editor = EditorProcess(command)
+ bin = None # TODO Add Unix command extraction
+
+ if bin is not None:
+ # Try to load the plugin for this editor
+ try:
+ module = 'Plugins.%s' % bin
+ Plugin = __import__(module, globals(), locals(),
+ ('EditorProcess',))
+ editor = Plugin.EditorProcess(self.content_file)
+ except (ImportError, AttributeError):
+ bin = None
+
+ if bin is None:
+ # Use the standard EditorProcess class for this editor
+ if win32:
+ file_insert = '%1'
+ else:
+ file_insert = '$1'
+
+ if command.find(file_insert) > -1:
+ command = command.replace(file_insert, self.content_file)
+ else:
+ command = '%s %s' % (command, self.content_file)
+
+ editor = EditorProcess(command)
if use_locks:
self.lock()