Skip to content

Commit b4bc53b

Browse files
author
Justus Pendleton
committed
fix [SF#297014]: roundup-admin interactive tracks uncommitted state
If you make changes from roundup-admin interactive it doesn't commit them. You have to do it yourself. It tries to be helpful and see if there is uncommitted data but it is looking at db.transactions which won't work for RDBMS backends. I saw a couple of options: 1. Don't have roundup-admin even try to help. You're on your own to remember to commit. This is how it has been for RDBMS backends, we would just remove the functionality from the others to make them all behave the same. Not very nice, though. 2. Always commit on exit. Admins have to remember to rollback if they don't like their changes if they don't want them. This mirrors how it works in non-interactive mode. 3. Have the backends keep track of dirty state. This would require duplicating code in all of the backends but would make the "dirty" state visible to all backend users. Does anyone but roundup-admin interactive even care, though? 4. Have roundup-admin keep track of dirty state. Quick and easy to implement but only roundup-admin sees this state. This patch implements #4 but it wouldn't be hard to convince me of #2 :)
1 parent 45022e3 commit b4bc53b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

roundup/admin.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: admin.py,v 1.106 2007-01-10 18:17:47 schlatterbeck Exp $
19+
# $Id: admin.py,v 1.107 2007-09-07 20:18:15 jpend Exp $
2020

2121
'''Administration commands for maintaining Roundup trackers.
2222
'''
@@ -75,6 +75,7 @@ def __init__(self):
7575
self.help[k[5:]] = getattr(self, k)
7676
self.tracker_home = ''
7777
self.db = None
78+
self.db_uncommitted = False
7879

7980
def get_class(self, classname):
8081
'''Get the class - raise an exception if it doesn't exist.
@@ -642,6 +643,7 @@ def do_set(self, args):
642643
except (TypeError, IndexError, ValueError), message:
643644
import traceback; traceback.print_exc()
644645
raise UsageError, message
646+
self.db_uncommitted = True
645647
return 0
646648

647649
def do_find(self, args):
@@ -813,6 +815,7 @@ def do_create(self, args):
813815
print apply(cl.create, (), props)
814816
except (TypeError, IndexError, ValueError), message:
815817
raise UsageError, message
818+
self.db_uncommitted = True
816819
return 0
817820

818821
def do_list(self, args):
@@ -995,6 +998,7 @@ def do_commit(self, args):
995998
they are successful.
996999
'''
9971000
self.db.commit()
1001+
self.db_uncommitted = False
9981002
return 0
9991003

10001004
def do_rollback(self, args):
@@ -1007,6 +1011,7 @@ def do_rollback(self, args):
10071011
immediately after would make no changes to the database.
10081012
'''
10091013
self.db.rollback()
1014+
self.db_uncommitted = False
10101015
return 0
10111016

10121017
def do_retire(self, args):
@@ -1030,6 +1035,7 @@ def do_retire(self, args):
10301035
raise UsageError, _('no such class "%(classname)s"')%locals()
10311036
except IndexError:
10321037
raise UsageError, _('no such %(classname)s node "%(nodeid)s"')%locals()
1038+
self.db_uncommitted = True
10331039
return 0
10341040

10351041
def do_restore(self, args):
@@ -1052,6 +1058,7 @@ def do_restore(self, args):
10521058
raise UsageError, _('no such class "%(classname)s"')%locals()
10531059
except IndexError:
10541060
raise UsageError, _('no such %(classname)s node "%(nodeid)s"')%locals()
1061+
self.db_uncommitted = True
10551062
return 0
10561063

10571064
def do_export(self, args, export_files=True):
@@ -1216,6 +1223,7 @@ class colon_separated(csv.excel):
12161223
print 'setting', classname, maxid+1
12171224
self.db.setid(classname, str(maxid+1))
12181225

1226+
self.db_uncommitted = True
12191227
return 0
12201228

12211229
def do_pack(self, args):
@@ -1254,6 +1262,7 @@ def do_pack(self, args):
12541262
elif m['date']:
12551263
pack_before = date.Date(value)
12561264
self.db.pack(pack_before)
1265+
self.db_uncommitted = True
12571266
return 0
12581267

12591268
def do_reindex(self, args, desre=re.compile('([A-Za-z]+)([0-9]+)')):
@@ -1424,7 +1433,7 @@ def interactive(self):
14241433
self.run_command(args)
14251434

14261435
# exit.. check for transactions
1427-
if self.db and self.db.transactions:
1436+
if self.db and self.db_uncommitted:
14281437
commit = raw_input(_('There are unsaved changes. Commit them (y/N)? '))
14291438
if commit and commit[0].lower() == 'y':
14301439
self.db.commit()

0 commit comments

Comments
 (0)