[Zope-CVS] CVS: Products/ExternalEditor - CHANGES.txt:1.36 ExternalEditor.py:1.21 README.txt:1.9

Casey Duncan casey@zope.com
Mon, 28 Oct 2002 11:18:03 -0500


Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv26235

Modified Files:
	CHANGES.txt ExternalEditor.py README.txt 
Log Message:
Merge in Tres' change adding path argument to externalEdit_
Updated docs


=== Products/ExternalEditor/CHANGES.txt 1.35 => 1.36 ===
--- Products/ExternalEditor/CHANGES.txt:1.35	Sun Sep 29 02:10:48 2002
+++ Products/ExternalEditor/CHANGES.txt	Mon Oct 28 11:18:02 2002
@@ -1,5 +1,10 @@
 External Editor Change Log
 
+    - The externalEdit_ object now accepts a path argument to the object to
+      edit, allowing URLs like: http://zope/externalEdit_?path=/some/object.
+      This allows external editor to play better with applications making use
+      of traversal magic of their own. Thanks to Tres Seaver.
+
     - Fixed NameError bug in unlock retry code. Thanks to Federico Sevilla III.
 
     - Added a workaround for non-compliant SSL servers. The software now


=== Products/ExternalEditor/ExternalEditor.py 1.20 => 1.21 ===
--- Products/ExternalEditor/ExternalEditor.py:1.20	Tue Aug 20 13:54:10 2002
+++ Products/ExternalEditor/ExternalEditor.py	Mon Oct 28 11:18:02 2002
@@ -42,22 +42,28 @@
     
     def __before_publishing_traverse__(self, self2, request):
         path = request['TraversalRequestNameStack']
-        target = path[-1]
-        request.set('target', target)
-        path[:] = []
+        if path:
+            target = path[-1]
+            request.set('target', target)
+            path[:] = []
+        else:
+            request.set('target', None)
     
-    def index_html(self, REQUEST, RESPONSE):
+    def index_html(self, REQUEST, RESPONSE, path=None):
         """Publish the object to the external editor helper app"""
         
         security = getSecurityManager()
-        parent = self.aq_parent
-        try:
-            ob = parent[REQUEST['target']] # Try getitem
-        except KeyError:
-            ob = getattr(parent, REQUEST['target']) # Try getattr
-        except AttributeError:
-            # Handle objects that are methods in ZClasses
-            ob = parent.propertysheets.methods[REQUEST['target']]
+        if path is None:
+            parent = self.aq_parent
+            try:
+                ob = parent[REQUEST['target']] # Try getitem
+            except KeyError:
+                ob = getattr(parent, REQUEST['target']) # Try getattr
+            except AttributeError:
+                # Handle objects that are methods in ZClasses
+                ob = parent.propertysheets.methods[REQUEST['target']]
+        else:
+            ob = self.restrictedTraverse( path )
         
         r = []
         r.append('url:%s' % ob.absolute_url())


=== Products/ExternalEditor/README.txt 1.8 => 1.9 ===
--- Products/ExternalEditor/README.txt:1.8	Sun Sep  1 01:03:42 2002
+++ Products/ExternalEditor/README.txt	Mon Oct 28 11:18:02 2002
@@ -295,6 +295,17 @@
          Edit Locally
       </a>
       
+    As an alternative, you can also pass the path the object you want to edit
+    directly to the externalEdit_ object when you call its index_html method.
+    It can be called either directly by URL or from a python script.
+    externalEdit_ will return the proper response data for the object to edit.
+    Here are some examples::
+
+      http://zopeserver/externalEdit_?path=/my_stuff/document
+      
+      return context.externalEdit_.index_html(
+          context.REQUEST, context.RESPONSE, path='/my_stuff/document')
+      
     External Editor also defines a global method that you can call to insert
     pencil icon links for appropriate objects. The method automatically checks
     if the object supports external editing and whether the user has the "Use