summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c390c1f)
raw | patch | inline | side by side (parent: c390c1f)
author | kedder <kedder@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 17 Mar 2003 22:03:08 +0000 (22:03 +0000) | ||
committer | kedder <kedder@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 17 Mar 2003 22:03:08 +0000 (22:03 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1597 57a73879-2fb5-44c3-a270-3262357dd7e2
index 258b4daf1ee7e947db0eeb0735ff9a06afcc71c5..c167c3cdd501a31fb5623b03ef5c6e619a47e9e7 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_anydbm.py,v 1.112 2003-03-16 22:24:54 kedder Exp $
+#$Id: back_anydbm.py,v 1.113 2003-03-17 22:03:04 kedder 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
if self.db.journaltag is None:
raise DatabaseError, 'Database open read-only'
- self.fireAuditors('restore', nodeid, None)
-
node = self.db.getnode(self.classname, nodeid)
+ # check if key property was overrided
+ key = self.getkey()
+ try:
+ id = self.lookup(node[key])
+ except KeyError:
+ pass
+ else:
+ raise KeyError, "Key property (%s) of retired node clashes with \
+ existing one (%s)" % (key, node[key])
+ # Now we can safely restore node
+ self.fireAuditors('restore', nodeid, None)
del node[self.db.RETIRED_FLAG]
self.db.setnode(self.classname, nodeid, node)
if self.do_journal:
index 8eae6946c454d0ad967735273f7a349ef859a049..13a6573f32345f32c5de122e124330a948d388fc 100755 (executable)
-# $Id: back_metakit.py,v 1.42 2003-03-16 22:24:54 kedder Exp $
+# $Id: back_metakit.py,v 1.43 2003-03-17 22:03:04 kedder Exp $
'''
Metakit backend for Roundup, originally by Gordon McMillan.
'''
if self.db.journaltag is None:
raise hyperdb.DatabaseError, 'Database open read-only'
+
+ # check if key property was overrided
+ key = self.getkey()
+ keyvalue = self.get(nodeid, key)
+ try:
+ id = self.lookup(keyvalue)
+ except KeyError:
+ pass
+ else:
+ raise KeyError, "Key property (%s) of retired node clashes with \
+ existing one (%s)" % (key, keyvalue)
+ # Now we can safely restore node
self.fireAuditors('restore', nodeid, None)
view = self.getview(1)
ndx = view.find(id=int(nodeid))
index 1c60cc7097d61abc8d764eb722eaa1d060f5c91c..27b5caff9b9d5345fc3ce7a9f3bc52f713c2c052 100644 (file)
-# $Id: rdbms_common.py,v 1.44 2003-03-16 22:24:55 kedder Exp $
+# $Id: rdbms_common.py,v 1.45 2003-03-17 22:03:08 kedder Exp $
''' Relational database (SQL) backend common code.
Basics:
if self.db.journaltag is None:
raise DatabaseError, 'Database open read-only'
- self.fireAuditors('restore', nodeid, None)
+ node = self.db.getnode(self.classname, nodeid)
+ # check if key property was overrided
+ key = self.getkey()
+ try:
+ id = self.lookup(node[key])
+ except KeyError:
+ pass
+ else:
+ raise KeyError, "Key property (%s) of retired node clashes with \
+ existing one (%s)" % (key, node[key])
+ self.fireAuditors('restore', nodeid, None)
# use the arg for __retired__ to cope with any odd database type
# conversion (hello, sqlite)
sql = 'update _%s set __retired__=%s where id=%s'%(self.classname,
diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py
index f78be2502611f2b7af025fb3efdfd46e7973ea1e..4ab22268aafdf57cd4b7b98022dad397576246ea 100644 (file)
--- a/roundup/hyperdb.py
+++ b/roundup/hyperdb.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: hyperdb.py,v 1.86 2003-02-26 04:55:57 richard Exp $
+# $Id: hyperdb.py,v 1.87 2003-03-17 22:03:03 kedder Exp $
"""
Hyperdatabase implementation, especially field types.
"""
raise NotImplementedError
+ def restore(self, nodeid):
+ '''Restpre a retired node.
+
+ Make node available for all operations like it was before retirement.
+ '''
+ raise NotImplementedError
+
def is_retired(self, nodeid):
'''Return true if the node is rerired
'''
diff --git a/test/test_db.py b/test/test_db.py
index e6860945038bc569623361e30ef7efece4a5b2ef..bc6720e9b96ad3b9608ce745f148e1a4367dde14 100644 (file)
--- a/test/test_db.py
+++ b/test/test_db.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_db.py,v 1.77 2003-03-16 22:24:56 kedder Exp $
+# $Id: test_db.py,v 1.78 2003-03-17 22:03:08 kedder Exp $
import unittest, os, shutil, time
# use the key again now that the old is retired
newid2 = self.db.user.create(username="spam")
self.assertNotEqual(newid, newid2)
+ # try to restore old node. this shouldn't succeed!
+ self.assertRaises(KeyError, self.db.user.restore, newid)
def testRetire(self):
self.db.issue.create(title="spam", status='1')
unittest.makeSuite(anydbmDBTestCase, 'test'),
unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test')
]
-# return unittest.TestSuite(l)
+ #return unittest.TestSuite(l)
from roundup import backends
p = []