Commit 8b552c65 authored by Jim Fulton's avatar Jim Fulton

Additional changes to support supplying batch size as a parameter.

parent 39470302
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
__doc__='''short description __doc__='''short description
$Id: Undo.py,v 1.7 1998/01/12 16:50:32 jim Exp $''' $Id: Undo.py,v 1.8 1998/01/12 17:58:39 jim Exp $'''
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
import Globals import Globals
from DateTime import DateTime from DateTime import DateTime
...@@ -20,25 +20,47 @@ from string import atof, find, atoi, split, rfind ...@@ -20,25 +20,47 @@ from string import atof, find, atoi, split, rfind
class UndoSupport: class UndoSupport:
manage_UndoForm=Globals.HTMLFile('undo', globals(), manage_UndoForm=Globals.HTMLFile(
batch_size=20, first_transaction=0, 'undo', globals(),
last_transaction=20) PrincipiaUndoBatchSize=20,
first_transaction=0, last_transaction=20)
def get_request_var_or_attr(self, name, default):
if hasattr(self, 'REQUEST'):
REQUEST=self.REQUEST
if REQUEST.has_key(name): return REQUEST[name]
if hasattr(self, name): v=getattr(self, name)
else: v=default
REQUEST[name]=v
return v
else:
if hasattr(self, name): v=getattr(self, name)
else: v=default
return v
def undoable_transactions(self, AUTHENTICATION_PATH=None, def undoable_transactions(self, AUTHENTICATION_PATH=None,
first_transaction=None, first_transaction=None,
last_transaction=None, last_transaction=None,
batch_size=20): PrincipiaUndoBatchSize=None):
if AUTHENTICATION_PATH is None: if AUTHENTICATION_PATH is None:
path=self.REQUEST['AUTHENTICATION_PATH'] path=self.REQUEST['AUTHENTICATION_PATH']
else: path=AUTHENTICATION_PATH else: path=AUTHENTICATION_PATH
if first_transaction is None: if first_transaction is None:
try: first_transaction=self.REQUEST['first_transaction'] first_transaction=self.get_request_var_or_attr(
except: first_transaction=0 'first_transaction', 0)
if PrincipiaUndoBatchSize is None:
PrincipiaUndoBatchSize=self.get_request_var_or_attr(
'PrincipiaUndoBatchSize', 20)
if last_transaction is None: if last_transaction is None:
try: last_transaction=self.REQUEST['last_transaction'] last_transaction=self.get_request_var_or_attr(
except: last_transaction=first_transaction+batch_size 'last_transaction',
first_transaction+PrincipiaUndoBatchSize)
db=self._p_jar.db db=self._p_jar.db
...@@ -90,6 +112,9 @@ Globals.default__class_init__(UndoSupport) ...@@ -90,6 +112,9 @@ Globals.default__class_init__(UndoSupport)
############################################################################## ##############################################################################
# #
# $Log: Undo.py,v $ # $Log: Undo.py,v $
# Revision 1.8 1998/01/12 17:58:39 jim
# Additional changes to support supplying batch size as a parameter.
#
# Revision 1.7 1998/01/12 16:50:32 jim # Revision 1.7 1998/01/12 16:50:32 jim
# Made some changes to enhance batch processing. # Made some changes to enhance batch processing.
# Batch size is also now a parameter. # Batch size is also now a parameter.
......
...@@ -17,14 +17,18 @@ ...@@ -17,14 +17,18 @@
button to undo the transactions. Note that even though a transaction button to undo the transactions. Note that even though a transaction
is shown below, you will not be able to undo it if later transactions is shown below, you will not be able to undo it if later transactions
modified objects that were modified by the transaction. modified objects that were modified by the transaction.
<table> <table>
<tr><td colspan=2 align=center><INPUT TYPE="SUBMIT" VALUE=" Undo "></td></tr> <tr><td colspan=2 align=center><INPUT TYPE="SUBMIT" VALUE=" Undo ">
</td></tr>
<tr><td></td></tr> <tr><td></td></tr>
<!--#if first_transaction--> <!--#if first_transaction-->
<tr><td colspan=2 align=center> <tr><td colspan=2 align=center>
<a href="manage_UndoForm?first_transaction:int=<!--#var <a href="manage_UndoForm?first_transaction:int=<!--#var
expr="first_transaction*2-last_transaction" expr="first_transaction*2-last_transaction"
-->&last_transaction:int=<!--#var first_transaction-->"> -->&last_transaction:int=<!--#var first_transaction
-->&PrincipiaUndoBatchSize:int=<!--#var PrincipiaUndoBatchSize
-->">
Later Transactions</h> Later Transactions</h>
</td></tr> </td></tr>
<!--#/if--> <!--#/if-->
...@@ -45,15 +49,18 @@ ...@@ -45,15 +49,18 @@
</tr> </tr>
<!--#/in--> <!--#/in-->
<tr><td colspan=2 align=center> <tr><td colspan=2 align=center>
<!--#if expr="_.len(undoable_transactions) == batch_size"--> <!--#if expr="_.len(undoable_transactions) == PrincipiaUndoBatchSize"-->
<a href="manage_UndoForm?first_transaction:int=<!--#var <a href="manage_UndoForm?first_transaction:int=<!--#var
last_transaction-->&last_transaction:int=<!--#var last_transaction-->&last_transaction:int=<!--#var
expr="last_transaction+batch_size"-->"> expr="last_transaction+PrincipiaUndoBatchSize"
-->&PrincipiaUndoBatchSize:int=<!--#var PrincipiaUndoBatchSize
-->">
Earlier Transactions</a> Earlier Transactions</a>
<!--#/if--> <!--#/if-->
</td></tr> </td></tr>
<tr><td></td></tr> <tr><td></td></tr>
<tr><td colspan=2 align=center><INPUT TYPE="SUBMIT" VALUE=" Undo "></td></tr> <tr><td colspan=2 align=center><INPUT TYPE="SUBMIT" VALUE=" Undo ">
</td></tr>
</table> </table>
</FORM> </FORM>
......
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