From 0f59079979e38b9b65354fac9125c0ba16966335 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 16 Dec 2001 10:53:38 +0000 Subject: [PATCH] take a copy of the node dict so that the subsequent set operation doesn't modify the oldvalues structure git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@472 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/back_anydbm.py | 11 ++++++++--- roundup/hyperdb.py | 11 +++++++++-- roundup/roundupdb.py | 12 +++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 219eb7c..b11a461 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.17 2001-12-14 23:42:57 richard Exp $ +#$Id: back_anydbm.py,v 1.18 2001-12-16 10:53:38 richard Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -188,7 +188,7 @@ class Database(hyperdb.Database): self.transactions.append((self._doSaveNode, (classname, nodeid, node))) def getnode(self, classname, nodeid, db=None): - ''' add the specified node to its class's db + ''' get a node from the database ''' if DEBUG: print 'getnode', (self, classname, nodeid, cldb) @@ -207,7 +207,7 @@ class Database(hyperdb.Database): return res def hasnode(self, classname, nodeid, db=None): - ''' add the specified node to its class's db + ''' determine if the database has a given node ''' if DEBUG: print 'hasnode', (self, classname, nodeid, cldb) @@ -338,6 +338,11 @@ class Database(hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.17 2001/12/14 23:42:57 richard +#yuck, a gdbm instance tests false :( +#I've left the debugging code in - it should be removed one day if we're ever +#_really_ anal about performace :) +# #Revision 1.16 2001/12/12 03:23:14 richard #Cor blimey this anydbm/whichdb stuff is yecchy. Turns out that whichdb #incorrectly identifies a dbm file as a dbhash file on my system. This has diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index b44e399..88376f2 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: hyperdb.py,v 1.41 2001-12-15 23:47:47 richard Exp $ +# $Id: hyperdb.py,v 1.42 2001-12-16 10:53:37 richard Exp $ __doc__ = """ Hyperdatabase implementation, especially field types. @@ -844,7 +844,11 @@ class Node: try: return self.cl.get(self.nodeid, name) except KeyError, value: - raise AttributeError, str(value) + # we trap this but re-raise it as AttributeError - all other + # exceptions should pass through untrapped + pass + # nope, no such attribute + raise AttributeError, str(value) def __getitem__(self, name): return self.cl.get(self.nodeid, name) def __setattr__(self, name, value): @@ -868,6 +872,9 @@ def Choice(name, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.41 2001/12/15 23:47:47 richard +# Cleaned up some bare except statements +# # Revision 1.40 2001/12/14 23:42:57 richard # yuck, a gdbm instance tests false :( # I've left the debugging code in - it should be removed one day if we're ever diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index e6c3e88..f57139e 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -15,13 +15,13 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.32 2001-12-15 23:48:35 richard Exp $ +# $Id: roundupdb.py,v 1.33 2001-12-16 10:53:37 richard Exp $ __doc__ = """ Extending hyperdb with types specific to issue-tracking. """ -import re, os, smtplib, socket +import re, os, smtplib, socket, copy import mimetools, MimeWriter, cStringIO import base64, mimetypes @@ -107,7 +107,9 @@ class Class(hyperdb.Class): raise KeyError, '"creation" and "activity" are reserved' for audit in self.auditors['set']: audit(self.db, self, nodeid, propvalues) - oldvalues = self.db.getnode(self.classname, nodeid) + # take a copy of the node dict so that the subsequent set + # operation doesn't modify the oldvalues structure + oldvalues = copy.deepcopy(self.db.getnode(self.classname, nodeid)) hyperdb.Class.set(self, nodeid, **propvalues) for react in self.reactors['set']: react(self.db, self, nodeid, oldvalues) @@ -504,6 +506,10 @@ class IssueClass(Class): # # $Log: not supported by cvs2svn $ +# Revision 1.32 2001/12/15 23:48:35 richard +# Added ROUNDUPDBSENDMAILDEBUG so one can test the sendmail method without +# actually sending mail :) +# # Revision 1.31 2001/12/15 19:24:39 rochecompaan # . Modified cgi interface to change properties only once all changes are # collected, files created and messages generated. -- 2.30.2