[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container - rename.pt:1.1.2.1 contents.py:1.7.2.4

runyaga runyaga@thisbox.com
Thu, 6 Feb 2003 11:05:06 -0500


Update of /cvs-repository/Zope3/src/zope/app/browser/container
In directory cvs.zope.org:/tmp/cvs-serv9195/browser/container

Modified Files:
      Tag: paris-copypasterename-branch
	contents.py 
Added Files:
      Tag: paris-copypasterename-branch
	rename.pt 
Log Message:
rename dialogue added
and renameObjects() method added to contents


=== Added File Zope3/src/zope/app/browser/container/rename.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
  <div metal:fill-slot="body" >
    <form method="POST" action="@@renameObjects.html">
    <div tal:repeat="id request/ids">
        <span>Name: <tal:block replace="id"/> </span>
        <span>
          New name:
          <input type="hidden" name="ids:list" value=""
                 tal:attributes="value id" />
          <input type="text" name="newids:list" value="" 
                 tal:attributes="value id" />
        </span>
    </div>
    <input type="submit" name="rename" value="rename" />
    </form>
  </div>
</body>
</html>


=== Zope3/src/zope/app/browser/container/contents.py 1.7.2.3 => 1.7.2.4 ===
--- Zope3/src/zope/app/browser/container/contents.py:1.7.2.3	Wed Feb  5 11:06:07 2003
+++ Zope3/src/zope/app/browser/container/contents.py	Thu Feb  6 11:04:35 2003
@@ -67,6 +67,14 @@
             info['size'] = sized_adapter
         return info
 
+    def renameObjects(self, ids, newids):
+        """Given a sequence of tuples of old, new ids we rename"""
+        container = self.context
+        for id, newid in zip(ids, newids):
+            if newid != id:
+                obj = traverse(container, id)
+                getAdapter(obj, IObjectMover).moveTo(container, newid)
+        self.request.response.redirect('@@contents.html')
 
     def removeObjects(self, ids):
         """Remove objects specified in a list of object ids"""
@@ -156,6 +164,8 @@
 
     contents = ViewPageTemplateFile('main.pt')
     contentsMacros = contents
+
+    rename = ViewPageTemplateFile('rename.pt')
 
     _index = ViewPageTemplateFile('index.pt')