[Zope-CVS] CVS: Products/ExternalEditor - CHANGES.txt:1.7 ExternalEditor.py:1.5 zopeedit.py:1.7
Casey Duncan
casey@zope.com
Thu, 6 Jun 2002 14:45:01 -0400
Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv25872
Modified Files:
CHANGES.txt ExternalEditor.py zopeedit.py
Log Message:
Various bug fixes.
Added new per domain configuration section.
Added capability to specify a complete command line (rather than just a file path) in the editor config option.
=== Products/ExternalEditor/CHANGES.txt 1.6 => 1.7 ===
+ - Added support for domain specific configuration options.
+
+ - Fixed trailing newline bug in encoded auth data coming from
+ CookieCrumbler. Thanks to Harald Koschinski.
+
+ - You can now pass command line arguments to the editor in the config file,
+ or wrap the editor in an xterm without using a shell script.
+
+ - Rewrote "Editor did not launch" error message so it makes more sense.
+
- Fixed https detection bug. External editor is now tested and working with
https. Many thanks to Hans-Dieter Stich and Martin Grönemeyer for their
assistance and ideas.
@@ -19,7 +29,7 @@
- Added improved support for editing CMF documents
- Eliminated spurious "Editor did not launch" errors on short sessions
- os when other errors occurred.
+ or when other errors occurred.
5/16/02 - 0.2 Release
=== Products/ExternalEditor/ExternalEditor.py 1.4 => 1.5 ===
#
##############################################################################
+"""$Id$
+"""
# Zope External Editor Product by Casey Duncan
@@ -49,8 +51,13 @@
if hasattr(ob, 'content_type'):
r.append('content_type:%s' % ob.content_type)
+
+ if REQUEST._auth[-1] == '\n':
+ auth = REQUEST._auth[:-1]
+ else:
+ auth = REQUEST._auth
- r.append('auth:%s' % REQUEST._auth)
+ r.append('auth:%s' % auth)
r.append('cookie:%s' % REQUEST.environ.get('HTTP_COOKIE',''))
r.append('')
=== Products/ExternalEditor/zopeedit.py 1.6 => 1.7 ===
#
##############################################################################
+"""$Id$
+"""
# Zope External Editor Helper Application by Casey Duncan
-__version__ = '0.1'
+__version__ = '0.3'
import sys, os, stat
from time import sleep
@@ -49,19 +51,31 @@
# Delegate to the ConfigParser instance
return getattr(self.config, name)
- def getAllOptions(self, meta_type, content_type):
+ def getAllOptions(self, meta_type, content_type, host_domain):
"""Return a dict of all applicable options for the
- given meta_type and content_type
+ given meta_type, content_type and host_domain
"""
opt = {}
sep = content_type.find('/')
general_type = '%s/*' % content_type[:sep]
+
+ # Divide up the domains segments and create a
+ # list of domains from the bottom up
+ host_domain = host_domain.split('.')
+ domains = []
+ for i in range(len(host_domain)):
+ domains.append('domain:%s' % '.'.join(host_domain[i:]))
+ domains.reverse()
+
sections = ('general',
'meta-type:%s' % meta_type,
'content-type:%s' % general_type,
- 'content-type:%s' % content_type)
+ 'content-type:%s' % content_type,
+ ) + tuple(domains)
+
for section in sections:
if self.config.has_section(section):
+ print 'found section:', section
for option in self.config.options(section):
opt[option] = self.config.get(section, option)
return opt
@@ -89,13 +103,16 @@
val = line[sep+1:]
metadata[key] = val
self.metadata = metadata
-
- self.options = self.config.getAllOptions(metadata['meta_type'],
- metadata.get('content_type',''))
# parse the incoming url
scheme, self.host, self.path = urlparse(metadata['url'])[:3]
self.ssl = scheme == 'https'
+
+ # Get all configuration options
+ self.options = self.config.getAllOptions(
+ metadata['meta_type'],
+ metadata.get('content_type',''),
+ self.host)
# Write the body of the input file to a separate file
body_file = (self.host + self.path).replace('/', ',')
@@ -145,7 +162,6 @@
editor = self.getEditor().split()
file = self.body_file
editor.append(file)
- print editor
last_fstat = os.stat(file)
pid = os.spawnvp(os.P_NOWAIT, editor[0], editor) # Note: Unix only
use_locks = int(self.options.get('use_locks'))
@@ -313,7 +329,6 @@
h = HTTPConnection(self.host)
h.putrequest(method, self.path)
- #h.putheader("Host", self.host) # required by HTTP/1.1
h.putheader('User-Agent', 'Zope External Editor/%s' % __version__)
h.putheader('Connection', 'close')
@@ -326,7 +341,7 @@
h.putheader("Authorization", self.metadata['auth'])
if self.metadata.get('cookie'):
- h.putheader("Cookie", self.metadata['cookie'])
+ h.putheader("Cookie", self.metadata['cookie']+'\n')
h.endheaders()
h.send(body)
@@ -335,7 +350,8 @@
# On error return a null response with error info
class NullResponse:
def getheader(n,d): return d
- def read(self): return '(No Response From Server)'
+ def read(self): return '(No Response From Server)\n\n%s' \
+ % sys.exc_info[2]
response = NullResponse()
response.reason = sys.exc_info()[1]