[Zope-CVS] CVS: Products/ExternalEditor - ExternalEditor.py:1.20.2.1

Tres Seaver tseaver@zope.com
Fri, 25 Oct 2002 11:03:55 -0400


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

Modified Files:
      Tag: tseaver-accept_path_argumentn-branch
	ExternalEditor.py 
Log Message:



  - Add option to pass target path to 'externalEdit_' as a parameter.
    In this case, the method just traverses the supplied path to get
    the object, rather than playing publishing traversal games to find it.


=== Products/ExternalEditor/ExternalEditor.py 1.20 => 1.20.2.1 ===
--- Products/ExternalEditor/ExternalEditor.py:1.20	Tue Aug 20 13:54:10 2002
+++ Products/ExternalEditor/ExternalEditor.py	Fri Oct 25 11:03:54 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())