Skip to content

Commit f3c1438

Browse files
author
Richard Jones
committed
take a copy of the node dict...
so that the subsequent set operation doesn't modify the oldvalues structure
1 parent a43f362 commit f3c1438

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

roundup/backends/back_anydbm.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.17 2001-12-14 23:42:57 richard Exp $
18+
#$Id: back_anydbm.py,v 1.18 2001-12-16 10:53:38 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -188,7 +188,7 @@ def savenode(self, classname, nodeid, node):
188188
self.transactions.append((self._doSaveNode, (classname, nodeid, node)))
189189

190190
def getnode(self, classname, nodeid, db=None):
191-
''' add the specified node to its class's db
191+
''' get a node from the database
192192
'''
193193
if DEBUG:
194194
print 'getnode', (self, classname, nodeid, cldb)
@@ -207,7 +207,7 @@ def getnode(self, classname, nodeid, db=None):
207207
return res
208208

209209
def hasnode(self, classname, nodeid, db=None):
210-
''' add the specified node to its class's db
210+
''' determine if the database has a given node
211211
'''
212212
if DEBUG:
213213
print 'hasnode', (self, classname, nodeid, cldb)
@@ -338,6 +338,11 @@ def rollback(self):
338338

339339
#
340340
#$Log: not supported by cvs2svn $
341+
#Revision 1.17 2001/12/14 23:42:57 richard
342+
#yuck, a gdbm instance tests false :(
343+
#I've left the debugging code in - it should be removed one day if we're ever
344+
#_really_ anal about performace :)
345+
#
341346
#Revision 1.16 2001/12/12 03:23:14 richard
342347
#Cor blimey this anydbm/whichdb stuff is yecchy. Turns out that whichdb
343348
#incorrectly identifies a dbm file as a dbhash file on my system. This has

roundup/hyperdb.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.41 2001-12-15 23:47:47 richard Exp $
18+
# $Id: hyperdb.py,v 1.42 2001-12-16 10:53:37 richard Exp $
1919

2020
__doc__ = """
2121
Hyperdatabase implementation, especially field types.
@@ -844,7 +844,11 @@ def __getattr__(self, name):
844844
try:
845845
return self.cl.get(self.nodeid, name)
846846
except KeyError, value:
847-
raise AttributeError, str(value)
847+
# we trap this but re-raise it as AttributeError - all other
848+
# exceptions should pass through untrapped
849+
pass
850+
# nope, no such attribute
851+
raise AttributeError, str(value)
848852
def __getitem__(self, name):
849853
return self.cl.get(self.nodeid, name)
850854
def __setattr__(self, name, value):
@@ -868,6 +872,9 @@ def Choice(name, *options):
868872

869873
#
870874
# $Log: not supported by cvs2svn $
875+
# Revision 1.41 2001/12/15 23:47:47 richard
876+
# Cleaned up some bare except statements
877+
#
871878
# Revision 1.40 2001/12/14 23:42:57 richard
872879
# yuck, a gdbm instance tests false :(
873880
# I've left the debugging code in - it should be removed one day if we're ever

roundup/roundupdb.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.32 2001-12-15 23:48:35 richard Exp $
18+
# $Id: roundupdb.py,v 1.33 2001-12-16 10:53:37 richard Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
2222
"""
2323

24-
import re, os, smtplib, socket
24+
import re, os, smtplib, socket, copy
2525
import mimetools, MimeWriter, cStringIO
2626
import base64, mimetypes
2727

@@ -107,7 +107,9 @@ def set(self, nodeid, **propvalues):
107107
raise KeyError, '"creation" and "activity" are reserved'
108108
for audit in self.auditors['set']:
109109
audit(self.db, self, nodeid, propvalues)
110-
oldvalues = self.db.getnode(self.classname, nodeid)
110+
# take a copy of the node dict so that the subsequent set
111+
# operation doesn't modify the oldvalues structure
112+
oldvalues = copy.deepcopy(self.db.getnode(self.classname, nodeid))
111113
hyperdb.Class.set(self, nodeid, **propvalues)
112114
for react in self.reactors['set']:
113115
react(self.db, self, nodeid, oldvalues)
@@ -504,6 +506,10 @@ def generateChangeNote(self, nodeid, oldvalues):
504506

505507
#
506508
# $Log: not supported by cvs2svn $
509+
# Revision 1.32 2001/12/15 23:48:35 richard
510+
# Added ROUNDUPDBSENDMAILDEBUG so one can test the sendmail method without
511+
# actually sending mail :)
512+
#
507513
# Revision 1.31 2001/12/15 19:24:39 rochecompaan
508514
# . Modified cgi interface to change properties only once all changes are
509515
# collected, files created and messages generated.

0 commit comments

Comments
 (0)