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

Chris Humphries zopemonkey@yahoo.com
Sat, 23 Mar 2002 18:23:35 -0500


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

Added Files:
      Tag: Zope-3x-branch
	IUndoManager.py Undo.py ZODBUndoManager.py __init__.py 
	undo.zcml undo_log.pt 
Log Message:

Undo: provides undo ability, like in zope 2
===========================================
undo_log.pt 	-> ZPT file for View
Undo.py		-> View
IUndoManager.py	-> Interface for undo
ZODBUndManager	-> Utility for View to do the
                   actual work. 
__init__.py	-> newline/requirement





=== Added File Zope3/lib/python/Zope/App/Undo/IUndoManager.py ===

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.
		"""
		


=== Added File Zope3/lib/python/Zope/App/Undo/Undo.py ===

from Zope.ComponentArchitecture import getUtility
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from IUndoManager import IUndoManager


class Undo(AttributePublisher):
    " Undo View "

    def __init__(self, context):
        self.context = context
        self.utility = getUtility(self.context, IUndoManager)
        
    index = PageTemplateFile('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()



=== Added File Zope3/lib/python/Zope/App/Undo/ZODBUndoManager.py ===
##############################################################################
#
# 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: ZODBUndoManager.py,v 1.1.2.1 2002/03/23 23:23:34 drauku Exp $
"""
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.undoLog()

    def undoTransaction(self, id_list):
        '''See interface IUndoManager'''

        for id in id_list:
            self.__db.undo(id)

    #
    ############################################################



=== Added File Zope3/lib/python/Zope/App/Undo/__init__.py ===



=== Added File Zope3/lib/python/Zope/App/Undo/undo.zcml ===
<zopeConfigure
   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'
>

<security:protectClass name="Zope.App.Undo."
	permission_id="Zope.ManageContent"
	methods="index, action, getUndoInfo" />

<browser:view name="undo"
	factory="Zope.App.Undo." />

</zopeConfigure>


=== Added File Zope3/lib/python/Zope/App/Undo/undo_log.pt ===
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<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="action" 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 container/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>