[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Undo - IUndoManager.py:1.2 Undo.py:1.2 ZODBUndoManager.py:1.2 __init__.py:1.2 undo.zcml:1.2 undo_log.pt:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:28:49 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Undo
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/Undo

Added Files:
	IUndoManager.py Undo.py ZODBUndoManager.py __init__.py 
	undo.zcml undo_log.pt 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.


=== Zope3/lib/python/Zope/App/Undo/IUndoManager.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+
+from Interface import Interface
+
+class IUndoManager(Interface):
+    " Interface for the Undo Manager "
+   
+    def getUndoInfo():
+        """ 
+        Gets all undo information.
+        Note: at the moment, doesnt care where called from
+
+        returns sequence of mapping objects by date desc
+                
+        keys of mapping objects:
+          id          -> internal id for zodb
+          user_name   -> name of user that last accessed the file
+          time        -> date of last access
+          description -> transaction description
+        """
+
+
+    def undoTransaction(id_list):
+        """
+        id_list will be a list of transaction ids.
+        iterate over each id in list, and undo
+        the transaction item.
+        """
+


=== Zope3/lib/python/Zope/App/Undo/Undo.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+
+from Zope.ComponentArchitecture import getUtility
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from IUndoManager import IUndoManager
+
+
+class Undo(BrowserView):
+    " Undo View "
+
+    def __init__(self, *args):
+        super(Undo, self).__init__(*args)
+        self.utility = getUtility(self.context, IUndoManager)
+        
+    index = ViewPageTemplateFile('undo_log.pt')
+
+
+    def action (self, id_list, REQUEST=None):
+        """
+        processes undo form and redirects to form again (if possible)
+        """
+        self.utility.undoTransaction(id_list)
+        
+        if REQUEST is not None:
+            REQUEST.response.redirect('index.html')
+            
+
+
+    def getUndoInfo(self):
+        return self.utility.getUndoInfo()
+


=== Zope3/lib/python/Zope/App/Undo/ZODBUndoManager.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+from Zope.App.Undo.IUndoManager import IUndoManager
+
+
+class ZODBUndoManager:
+    """Implement the basic undo management api for a single ZODB database.
+    """
+    
+    __implements__ =  IUndoManager
+
+    def __init__(self, db):
+        self.__db = db
+
+    ############################################################
+    # Implementation methods for interface
+    # Zope.App.Undo.IUndoManager.
+
+    def getUndoInfo(self):
+        '''See interface IUndoManager'''
+        
+        return self.__db.undoInfo()
+
+    def undoTransaction(self, id_list):
+        '''See interface IUndoManager'''
+
+        for id in id_list:
+            self.__db.undo(id)
+
+    #
+    ############################################################
+


=== Zope3/lib/python/Zope/App/Undo/__init__.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+


=== Zope3/lib/python/Zope/App/Undo/undo.zcml 1.1 => 1.2 ===
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:security='http://namespaces.zope.org/security'
+   xmlns:zmi='http://namespaces.zope.org/zmi'
+   xmlns:browser='http://namespaces.zope.org/browser'
+>
+
+<browser:view
+    permission="Zope.ManageContent"
+    factory="Zope.App.Undo." >
+
+   <browser:page name="undoForm.html" attribute="index" />
+   <browser:page name="undo.html" attribute="action" />
+</browser:view>
+
+</zopeConfigure>


=== Zope3/lib/python/Zope/App/Undo/undo_log.pt 1.1 => 1.2 ===
+<html metal:use-macro="views/standard_macros/page">
+
+<head>
+<title>Undo Title</title>
+<link rel="stylesheet" type="text/css" href="/manage_page_style.css">
+</head>
+
+<body>
+<div metal:fill-slot="body">
+
+<form action="@@undo.html" method="post">
+
+<p class="form-help">
+This application's transactional feature allows you to easily undo changes 
+made to the application's settings or data. You can revert the application 
+to a &quot;snapshot&quot; of it's state at a previous point in time.
+</p>
+
+<p class="form-help">
+Select one or more transactions below and then click on the &quot;Undo&quot;
+button to undo those transactions.  Note that even though a transaction
+is shown below, you may not be able to undo it if later transactions
+modified objects that were modified by a selected transaction.
+</p>
+
+
+
+<a name="t_list" />
+
+<table width="100%" cellspacing="0" cellpadding="2" border="0">
+
+  <span tal:define="global undoInfo view/getUndoInfo" />
+  <div tal:repeat="undoitem undoInfo">
+  <span tal:condition="repeat/undoitem/odd" ><span tal:define="global rowclass string:row-hilite"/> </span>
+  <span tal:condition="repeat/undoitem/even" ><span tal:define="global rowclass string:row-normal"/> </span>
+
+  <tr tal:attributes="class rowclass">
+    <td width="16" align="left" valign="top">
+      <input type=checkbox name="id_list:list" value="-1" tal:attributes="value undoitem/id"/>
+    </td>
+    <td align="left" valign="top">
+    <div class="list-item">
+     
+     <span tal:content="undoitem/description"> description </span>
+     by
+     <strong><span tal:content="undoitem/user_name"> user_name </span></strong>
+ 
+    </div>
+    </td>
+<!--
+    <td align="right" valign="top" colspan="2" nowrap>
+    <div class="list-item" tal:content="undoitem/time">
+      blah date
+    </div>
+    </td>
+-->
+  </tr>
+
+
+<!--
+
+  <tr class="row-hilite">
+    <td width="16" align="left" valign="top">
+    <input type="checkbox" name="transaction_info:list" 
+     value="QTBOekEwdWl6ZmNBQUFBQUV2M0RDdw==
+ 2002/03/17 00:23:17.7272 US/Eastern /test_area/chumphries/devis_internal_site/people/addDTMLMethod " />
+    </td>
+    <td align="left" valign="top">
+    <div class="list-item">
+    /test_area/chumphries/devis_internal_site/people/addDTMLMethod by <strong> chumphries</strong>
+    </div>
+    </td>
+    <td align="right" valign="top" colspan="2" nowrap>
+    <div class="list-item">
+    2002-03-17 12:23:17 AM
+    </div>
+    </td>
+  </tr>
+
+  </div>
+
+  <tr class="row-normal">
+    <td width="16" align="left" valign="top">
+    <input type="checkbox" name="transaction_info:list"
+     value="QTBOeTQzWURnOVVBQUFBQUV2M0FkUQ==
+ 2002/03/16 23:51:27.6595 US/Eastern /test_area/chumphries/devis_internal_site/manage_renameObjects " />
+    </td>
+    <td align="left" valign="top">
+    <div class="list-item">
+    /test_area/chumphries/devis_internal_site/manage_renameObjects by <strong> chumphries</strong>
+    </div>
+    </td>
+    <td align="right" valign="top" colspan="2" nowrap>
+    <div class="list-item">
+    2002-03-16 11:51:27 PM
+    </div>
+    </td>
+  </tr>
+
+-->
+
+
+</div>
+<tr><td><input type="submit" value="Undo"></td></tr>
+</table>
+</form>
+
+</div>
+</body>
+</html>
+