[Zope-CVS] CVS: Products/ExternalEditor - CHANGES.txt:1.29 ExternalEditor.py:1.18 __init__.py:1.2 manage_main.dtml:1.4

Casey Duncan casey@zope.com
Tue, 20 Aug 2002 00:48:43 -0400


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

Modified Files:
	CHANGES.txt ExternalEditor.py __init__.py manage_main.dtml 
Log Message:
Factored out link generation to a separate method that is registered globally
Updated manage_main replacement to use this method


=== Products/ExternalEditor/CHANGES.txt 1.28 => 1.29 ===
--- Products/ExternalEditor/CHANGES.txt:1.28	Sun Aug 18 22:59:23 2002
+++ Products/ExternalEditor/CHANGES.txt	Tue Aug 20 00:48:43 2002
@@ -1,5 +1,9 @@
 External Editor Change Log
 
+    - Factored out external editor link generator. Product now registers
+      a global method "externalEditLink_" which can be called to generate
+      the external editor icon link for any object.
+
     - External editing is now governed by the "Use external editor" permission
       to allow non-managers to use it. Users must also have the permissions to
       edit/modify the objects they edit, plus do WebDAV locking if desired.


=== Products/ExternalEditor/ExternalEditor.py 1.17 => 1.18 ===
--- Products/ExternalEditor/ExternalEditor.py:1.17	Sun Aug 18 22:59:23 2002
+++ Products/ExternalEditor/ExternalEditor.py	Tue Aug 20 00:48:43 2002
@@ -29,13 +29,15 @@
     def wl_isLocked(ob):
         return 0
 
+ExternalEditorPermission = 'Use external editor'
+
 class ExternalEditor(Acquisition.Implicit):
     """Create a response that encapsulates the data needed by the
        ZopeEdit helper application
     """
     
     security = ClassSecurityInfo()
-    security.declareObjectProtected('Use external editor')
+    security.declareObjectProtected(ExternalEditorPermission)
     
     def __before_publishing_traverse__(self, self2, request):
         path = request['TraversalRequestNameStack']
@@ -127,3 +129,24 @@
         return join(r, '\n')
 
 InitializeClass(ExternalEditor)
+
+def EditLink(self, object):
+    """Insert the external editor link to an object if appropriate"""
+    base = Acquisition.aq_base(object)
+    user = getSecurityManager().getUser()
+    editable = (hasattr(base, 'manage_FTPget')
+                or hasattr(base, 'EditableBody')
+                or hasattr(base, 'document_src')
+                or hasattr(base, 'read'))
+    if editable and user.has_permission(ExternalEditorPermission, object):
+        return ('<a href="%s/externalEdit_/%s" '
+                'title="Edit using external editor">'
+                '<img src="%s/misc_/ExternalEditor/edit_icon" '
+                'align="middle" hspace="2" border="0" alt="External Editor" />'
+                '</a>' % (object.aq_parent.absolute_url(), 
+                          object.getId(),
+                          object.REQUEST.BASEPATH1)
+               )
+    else:
+        return ''
+                


=== Products/ExternalEditor/__init__.py 1.1.1.1 => 1.2 ===
--- Products/ExternalEditor/__init__.py:1.1.1.1	Thu May 16 15:19:49 2002
+++ Products/ExternalEditor/__init__.py	Tue Aug 20 00:48:43 2002
@@ -17,25 +17,21 @@
 from Globals import ImageFile, DTMLFile
 from OFS.ObjectManager import ObjectManager
 from OFS.Application import Application
-from ExternalEditor import ExternalEditor
+from OFS.FindSupport import FindSupport
+from ExternalEditor import ExternalEditor, EditLink
 
 # Add the icon and the edit method to the misc_ namespace
 
 misc_ = {'edit_icon': ImageFile('edit_icon.gif', globals())}
 
-# Monkey patch in our manage_main for Object Manager
+# Insert the global external editor resources
+methods = {'externalEdit_': ExternalEditor(),
+           'externalEditLink_': EditLink}
 
+# Monkey patch in our manage_main for Object Manager
 ObjectManager.manage_main = DTMLFile('manage_main', globals())
+print 'patched'
 
-# Monkey patch the application object
-exedit = Application.externalEdit_ = ExternalEditor()
-
-def initialize(context):
-    # Compensate for past inadequacies
-    app = context._ProductContext__app
-    if app.externalEdit_ is not exedit and \
-       app.externalEdit_.__class__  is ExternalEditor:
-        try:
-            del app.externalEdit_
-        except:
-            pass
+# Add our patch for the find results template
+#FindSupport.manage_findResult=DTMLFile('findResult', globals(),
+#                                       management_view='Find')


=== Products/ExternalEditor/manage_main.dtml 1.3 => 1.4 === (438/538 lines abridged)
--- Products/ExternalEditor/manage_main.dtml:1.3	Sun Aug 18 22:59:23 2002
+++ Products/ExternalEditor/manage_main.dtml	Tue Aug 20 00:48:43 2002
@@ -1,268 +1,267 @@
-<dtml-var manage_page_header>
-<dtml-var manage_tabs>
-
-<script type="text/javascript">
-<!-- 
-
-isSelected = false;
-
-function toggleSelect() {
-  if (isSelected == false) {
-    for (i = 0; i < document.objectItems.length; i++)
-      document.objectItems.elements[i].checked = true ;
-      isSelected = true;
-      document.objectItems.selectButton.value = "Deselect All";
-      return isSelected;
-  }
-  else {
-    for (i = 0; i < document.objectItems.length; i++)
-      document.objectItems.elements[i].checked = false ;
-      isSelected = false;
-      document.objectItems.selectButton.value = "Select All";
-      return isSelected;       
-  }
-}
-
-//-->
-</script>
-
-<dtml-unless skey><dtml-call expr="REQUEST.set('skey', 'id')"></dtml-unless>
-<dtml-unless rkey><dtml-call expr="REQUEST.set('rkey', '')"></dtml-unless>
-
-<!-- Add object widget -->
-<br />
-<dtml-if filtered_meta_types>
-  <table width="100%" cellspacing="0" cellpadding="0" border="0">
-  <tr>
-  <td align="left" valign="top">&nbsp;</td>
-  <td align="right" valign="top">
-  <div class="form-element">
-  <form action="&dtml-URL1;/" method="get">
-  <dtml-if "_.len(filtered_meta_types) > 1">
-    <select class="form-element" name=":action" 
-     onChange="location.href='&dtml-URL1;/'+this.options[this.selectedIndex].value">
-    <option value="manage_workspace" disabled>Select type to add...</option>
-    <dtml-in filtered_meta_types mapping sort=name>
-    <option value="&dtml.url_quote-action;">&dtml-name;</option>
-    </dtml-in>

[-=- -=- -=- 438 lines omitted -=- -=- -=-]

+</table>
+
+<dtml-else>
+<table cellspacing="0" cellpadding="2" border="0">
+<tr>
+<td>
+<div class="std-text">
+There are currently no items in <em>&dtml-title_or_id;</em>
+<br /><br />
+</div>
+<dtml-unless dontAllowCopyAndPaste>
+<dtml-if cb_dataValid>
+<div class="form-element">
+<input class="form-element" type="submit" name="manage_pasteObjects:method" 
+ value="Paste" />
+</div>
+</dtml-if>
+</dtml-unless>
+<dtml-if "_.SecurityCheckPermission('Import/Export objects', this())">
+<input class="form-element" type="submit"
+  name="manage_importExportForm:method" value="Import/Export" />
+</dtml-if>
+</td>
+</tr>
+</table>
+</dtml-if>
+</form>
+
+<dtml-if update_menu>
+<script type="text/javascript">
+<!--
+window.parent.update_menu();
+//-->
+</script>
+</dtml-if>
+
+<dtml-var manage_page_footer>
+
+
+
+
+
+
+
+
+
+
+
+
+