Commit 539a73e5 authored by Jim Fulton's avatar Jim Fulton

Carry descriptive info in the input form so that, when a transaction

is undone, the application can note the fact in the undoing
transaction. This is extremely desireable when doing transactional
undo, so that you can keep track of what the undoing transactions
actually (un)did.
parent a2f9b2ae
......@@ -84,13 +84,14 @@
##############################################################################
__doc__='''short description
$Id: Undo.py,v 1.24 2001/01/11 22:42:42 chrism Exp $'''
__version__='$Revision: 1.24 $'[11:-2]
$Id: Undo.py,v 1.25 2001/04/12 18:49:02 jim Exp $'''
__version__='$Revision: 1.25 $'[11:-2]
import Globals, ExtensionClass
from DateTime import DateTime
from string import atof, find, atoi, split, rfind, join
from AccessControl import getSecurityManager
import base64
class UndoSupport(ExtensionClass.Base):
......@@ -164,7 +165,21 @@ class UndoSupport(ExtensionClass.Base):
r=Globals.UndoManager.undoInfo(
first_transaction, last_transaction, spec)
for d in r: d['time']=DateTime(d['time'])
encode = base64.encodestring
for d in r:
d['time']=t=DateTime(d['time'])
desc = d['description']
tid=d['id']
if desc:
desc = split(desc)
d1=desc[0]
desc = join(desc[1:])
if len(desc) > 60: desc = desc[:56]+' ...'
tid = "%s %s %s %s" % (encode64(tid), t, d1, desc)
else:
tid = "%s %s" % (encode64(tid), t)
d['id']=tid
return r
......@@ -172,8 +187,12 @@ class UndoSupport(ExtensionClass.Base):
"""
"""
undo=Globals.UndoManager.undo
for i in transaction_info: undo(i)
for tid in transaction_info:
tid=split(tid)
if tid:
get_transaction().note("Undo %s" % join(tid[1:]))
tid=decode64(tid[0])
undo(tid)
if REQUEST is None: return
REQUEST['RESPONSE'].redirect("%s/manage_UndoForm" % REQUEST['URL1'])
......@@ -195,3 +214,21 @@ class Prefix:
return rval
########################################################################
# Blech, need this cause binascii.b2a_base64 is too pickly
import binascii
def encode64(s, b2a=binascii.b2a_base64):
if len(s) < 58: return b2a(s)
r=[]; a=r.append
for i in range(0, len(s), 57):
a(b2a(s[i:i+57])[:-1])
return join(r,'')
def decode64(s, a2b=binascii.a2b_base64):
__traceback_info__=len(s), `s`
return a2b(s+'\n')
del binascii
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment