summaryrefslogtreecommitdiff
path: root/Mailman/database/dbcontext.py
diff options
context:
space:
mode:
authorbwarsaw2006-12-30 22:47:12 +0000
committerbwarsaw2006-12-30 22:47:12 +0000
commita951f422ff1adb5533b5ec52495c0c25e060cab9 (patch)
tree173769d9aca45dae6c0824bf61f970908efc9027 /Mailman/database/dbcontext.py
parentf4a456a83b630feb294724ab462c87ca1ce1c3ae (diff)
downloadmailman-a951f422ff1adb5533b5ec52495c0c25e060cab9.tar.gz
mailman-a951f422ff1adb5533b5ec52495c0c25e060cab9.tar.zst
mailman-a951f422ff1adb5533b5ec52495c0c25e060cab9.zip
Diffstat (limited to 'Mailman/database/dbcontext.py')
-rw-r--r--Mailman/database/dbcontext.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/Mailman/database/dbcontext.py b/Mailman/database/dbcontext.py
index b812c9b77..a13f20498 100644
--- a/Mailman/database/dbcontext.py
+++ b/Mailman/database/dbcontext.py
@@ -98,19 +98,33 @@ class DBContext(object):
return
txn = self.session.create_transaction()
mref = MlistRef(mlist, self._unlock_mref)
- self._mlist_txns[mlist.fqdn_listname] = txn
+ # If mlist.host_name is changed, its fqdn_listname attribute will no
+ # longer match, so its transaction will not get committed when the
+ # list is saved. To avoid this, store on the mlist object the key
+ # under which its transaction is stored.
+ txnkey = mlist._txnkey = mlist.fqdn_listname
+ self._mlist_txns[txnkey] = txn
def api_unlock(self, mlist):
- txn = self._mlist_txns.pop(mlist.fqdn_listname, None)
+ try:
+ txnkey = mlist._txnkey
+ except AttributeError:
+ return
+ txn = self._mlist_txns.pop(txnkey, None)
if txn is not None:
txn.rollback()
+ del mlist._txnkey
def api_save(self, mlist):
# When dealing with MailLists, .Save() will always be followed by
# .Unlock(). However lists can also be unlocked without saving. But
# if it's been locked it will always be unlocked. So the rollback in
# unlock will essentially be no-op'd if we've already saved the list.
- txn = self._mlist_txns.pop(mlist.fqdn_listname, None)
+ try:
+ txnkey = mlist._txnkey
+ except AttributeError:
+ return
+ txn = self._mlist_txns.pop(txnkey, None)
if txn is not None:
txn.commit()