[Zope-dev] Multiple Rename Patch

Lahser, Andrew andrew_lahser@merck.com
Wed, 16 Feb 2000 19:11:54 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--Boundary_(ID_XctGJ626SCnwBnuzacpg6A)
Content-type: text/plain
Content-transfer-encoding: 7BIT

There was a recent tread that discussed how folks were _managing_ their zope

websites. Surprisingly, many of us actually use the web interface even
though
ftp and webdav are available. 

To this end, I have a patch that allows multiple rename of Zope items in the
web
management interface; instead of just the first item. This patch was
originally
submitted to the collector last December, but this new version works against
Zope 2.1.3 and 2.1.4. I haven't tested it against CVS.

Cheers,
Drew

**Brief install instructions.**

cd ZopeDir
cd lib/python/OFS
patch -c CopySupport.py /path/to/patch/CopySupport.diff
patch -c renameForm.dtml /path/to/patch/renameForm.diff



 <<CopySupport.diff>>  <<renameForm.diff>> 

--Boundary_(ID_XctGJ626SCnwBnuzacpg6A)
Content-type: application/octet-stream; name=CopySupport.diff
Content-disposition: attachment; filename=CopySupport.diff

*** original_CopySupport.py	Wed Nov 03 11:05:20 1999
--- CopySupport.py	Thu Feb 10 13:50:14 2000
***************
*** 101,107 ****
      __ac_permissions__=(
          ('View management screens',
           ('manage_cutObjects', 'manage_copyObjects', 'manage_pasteObjects',
!           'manage_renameForm', 'manage_renameObject',)),
          )
  
  
--- 101,107 ----
      __ac_permissions__=(
          ('View management screens',
           ('manage_cutObjects', 'manage_copyObjects', 'manage_pasteObjects',
!           'manage_renameForm', 'manage_renameObjects', 'manage_renameObjects',)),
          )
  
  
***************
*** 119,124 ****
--- 119,127 ----
      def manage_CopyContainerFirstItem(self, REQUEST):
          return self._getOb(REQUEST['ids'][0])        
  
+     def manage_CopyContainerAllItems(self, REQUEST):
+         return map(lambda i, s=self: s._getOb(i), tuple(REQUEST['ids']))
+ 
      def manage_cutObjects(self, ids, REQUEST=None):
          """Put a reference to the objects named in ids in the clip board"""
          if type(ids) is type(''):
***************
*** 239,244 ****
--- 242,258 ----
  
  
      manage_renameForm=Globals.HTMLFile('renameForm', globals())
+ 
+     def manage_renameObjects(self, ids, new_ids, REQUEST=None):
+         """Rename several sub-objects"""
+         if len(ids) != len(new_ids):
+             raise 'BadRequst','Please rename each listed object.'
+         for i in range(len(ids)):
+             if ids[i] != new_ids[i]:
+                 self.manage_renameObject(ids[i], new_ids[i], REQUEST)
+         if REQUEST is not None:
+             return self.manage_main(self, REQUEST, update_menu=1)
+         return None
  
      def manage_renameObject(self, id, new_id, REQUEST=None):
          """Rename a particular sub-object"""

--Boundary_(ID_XctGJ626SCnwBnuzacpg6A)
Content-type: application/octet-stream; name=renameForm.diff
Content-disposition: attachment; filename=renameForm.diff

*** original_renameForm.dtml	Wed Nov 03 13:56:32 1999
--- renameForm.dtml	Tue Feb 15 15:36:16 2000
***************
*** 1,55 ****
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  <HTML lang="en">
  <HEAD>
! <TITLE>Rename Item</TITLE>
  </HEAD>
  <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
! <dtml-if expr="_.hasattr(REQUEST, 'ids') and REQUEST['ids']">
! <dtml-with expr="manage_CopyContainerFirstItem(REQUEST)">
! <dtml-if cb_isMoveable>
! <H2>Rename <dtml-var meta_type></H2>
  <P>
  <FORM ACTION="." METHOD="POST">
  <TABLE CELLSPACING="0">
  <TR>
    <TD ALIGN="LEFT" VALIGN="TOP">
    <IMG SRC="<dtml-var SCRIPT_NAME>/<dtml-var icon>" ALT="" BORDER="0">
    </TD>
    <TD ALIGN="LEFT" VALIGN="TOP">
    <dtml-var id>
    </TD>
- </TR>
- <TR>
    <TD ALIGN="LEFT" VALIGN="TOP">
    <STRONG>to:</STRONG>
    </TD>
    <TD ALIGN="LEFT" VALIGN="TOP">
!   <INPUT TYPE="TEXT" NAME="new_id" SIZE="20">
    </TD>
  </TR>
  <TR>
  <TD></TD>
! <TD>
!   <INPUT TYPE="HIDDEN" NAME="id" VALUE="<dtml-var id html_quote>">
    <INPUT TYPE="HIDDEN" NAME=":default_method" VALUE="manage_renameObject">
!   <INPUT TYPE="submit" NAME="manage_renameObject:method" VALUE=" Ok ">
    <INPUT TYPE="submit" NAME="manage_main:method" VALUE="Cancel">
  </TD>
  </TR>
  </TABLE>
  </FORM>
- <dtml-else>
- <FORM ACTION="manage_main" METHOD="GET">
- <CENTER>
- <BR><BR>
- The item <EM><dtml-var id></EM> does not support this operation.
- <P>
- <INPUT TYPE="submit" NAME="submit" VALUE=" Ok ">
- </CENTER>
- </FORM>
- </dtml-if>
  
- </dtml-with>
  <dtml-else>
  <FORM ACTION="manage_main" METHOD="GET">
  <CENTER>
--- 1,48 ----
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  <HTML lang="en">
  <HEAD>
! <TITLE>Rename Items</TITLE>
  </HEAD>
  <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
! <dtml-if expr="_.hasattr(REQUEST, 'ids')">
! <H2>Rename Items</H2>
  <P>
  <FORM ACTION="." METHOD="POST">
  <TABLE CELLSPACING="0">
+ <dtml-in expr="manage_CopyContainerAllItems(REQUEST)">
  <TR>
    <TD ALIGN="LEFT" VALIGN="TOP">
    <IMG SRC="<dtml-var SCRIPT_NAME>/<dtml-var icon>" ALT="" BORDER="0">
    </TD>
+ <dtml-if cb_isMoveable>
    <TD ALIGN="LEFT" VALIGN="TOP">
    <dtml-var id>
    </TD>
    <TD ALIGN="LEFT" VALIGN="TOP">
    <STRONG>to:</STRONG>
    </TD>
    <TD ALIGN="LEFT" VALIGN="TOP">
!   <INPUT TYPE="HIDDEN" NAME="ids:list" VALUE="<dtml-var id html_quote>">
!   <INPUT TYPE="TEXT" NAME="new_ids:list" VALUE="<dtml-var id>" SIZE="20">
!   </TD>
! <dtml-else>
!   <TD ALIGN="LEFT" VALIGN="TOP" COLSPAN="3">
!   <dtml-var id> may not be renamed.
    </TD>
+ </dtml-if>
  </TR>
+ </dtml-in>
  <TR>
  <TD></TD>
! <TD COLSPAN="3">
    <INPUT TYPE="HIDDEN" NAME=":default_method" VALUE="manage_renameObject">
!   <INPUT TYPE="submit" NAME="manage_renameObjects:method" VALUE=" Ok ">
    <INPUT TYPE="submit" NAME="manage_main:method" VALUE="Cancel">
  </TD>
  </TR>
  </TABLE>
  </FORM>
  
  <dtml-else>
  <FORM ACTION="manage_main" METHOD="GET">
  <CENTER>

--Boundary_(ID_XctGJ626SCnwBnuzacpg6A)--