diff --git a/xedit/README.txt b/xedit/README.txt
new file mode 100644
index 0000000..cd92467
--- /dev/null
+++ b/xedit/README.txt
@@ -0,0 +1,10 @@
+External Editor
+===============
+
+ ($Id$)
+
+ >>> from zope.app.testing import ztapi
+ >>> from zope.app import zapi
+
+ >>> from cybertools.xedit import interfaces
+ >>> from cybertools.xedit.browser import ExternalEditorView
diff --git a/xedit/__init__.py b/xedit/__init__.py
new file mode 100644
index 0000000..4bc90fb
--- /dev/null
+++ b/xedit/__init__.py
@@ -0,0 +1,4 @@
+"""
+$Id$
+"""
+
diff --git a/xedit/browser.py b/xedit/browser.py
new file mode 100644
index 0000000..96068ad
--- /dev/null
+++ b/xedit/browser.py
@@ -0,0 +1,80 @@
+#
+# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+"""
+(View) class(es) for the external editor functionality.
+
+$Id$
+"""
+
+from zope.app import zapi
+from zope.event import notify
+from zope.app.event.objectevent import ObjectModifiedEvent
+from zope.cachedescriptors.property import Lazy
+from zope.security.proxy import removeSecurityProxy
+
+
+class ExternalEditorView(object):
+
+ # TODO: don't access context.data directly but via an IReadFile adapter
+
+ def load(self):
+ context = removeSecurityProxy(self.context)
+ data = context.data
+ r = []
+ r.append('url:' + zapi.absoluteURL(context, self.request))
+ r.append('meta_type:' + '.'.join((context.__module__, context.__class__.__name__)))
+ auth = self.request.get('_auth')
+ if auth:
+ print 'ExternalEditorView: auth = ', auth
+ if auth.endswith('\n'):
+ auth = auth[:-1]
+ r.append('auth:' + auth)
+ cookie = self.request.get('HTTP_COOKIE','')
+ if cookie:
+ r.append('cookie:' + cookie)
+ r.append('')
+ r.append(data)
+ result = '\n'.join(r)
+ self.setHeaders(len(result))
+ return fromUnicode(result)
+
+ def save(self):
+ data = self.request.get('editor.data')
+ if data:
+ self.context.data = data
+ notify(ObjectModifiedEvent)
+
+ def lock(self):
+ pass
+
+ def unlock(self):
+ pass
+
+ def setHeaders(self, size):
+ response = self.request.response
+ response.setHeader('Content-Type', 'application/x-zope-xedit')
+ response.setHeader('Content-Length', size)
+
+
+def fromUnicode(text):
+ if not text:
+ return ''
+ if isinstance(text, unicode):
+ return text.encode('UTF-8')
+ return text
diff --git a/xedit/configure.zcml b/xedit/configure.zcml
new file mode 100644
index 0000000..44182de
--- /dev/null
+++ b/xedit/configure.zcml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xedit/cybertools.xedit-configure.zcml b/xedit/cybertools.xedit-configure.zcml
new file mode 100644
index 0000000..8a83756
--- /dev/null
+++ b/xedit/cybertools.xedit-configure.zcml
@@ -0,0 +1 @@
+
diff --git a/xedit/interfaces.py b/xedit/interfaces.py
new file mode 100644
index 0000000..8fe506c
--- /dev/null
+++ b/xedit/interfaces.py
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+"""
+interface definitions for the external editor.
+
+$Id$
+"""
+
+from zope.interface import Interface, Attribute
+
+
diff --git a/xedit/tests.py b/xedit/tests.py
new file mode 100755
index 0000000..47e4cf7
--- /dev/null
+++ b/xedit/tests.py
@@ -0,0 +1,14 @@
+# $Id$
+
+import unittest, doctest
+from zope.testing.doctestunit import DocFileSuite
+
+
+def test_suite():
+ flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
+ return unittest.TestSuite((
+ DocFileSuite('README.txt', optionflags=flags),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')