|
1 | | -# $Id: back_metakit.py,v 1.56 2004-01-26 17:07:56 wc2so1 Exp $ |
| 1 | +# $Id: back_metakit.py,v 1.57 2004-01-27 18:10:48 wc2so1 Exp $ |
2 | 2 | ''' |
3 | 3 | Metakit backend for Roundup, originally by Gordon McMillan. |
4 | 4 |
|
|
94 | 94 | # 12 Enumerated READ and READWRITE for the getview and getindexedview |
95 | 95 | # These will probably be removed because they are not used |
96 | 96 | # |
97 | | -# Known Current Bugs: |
98 | | -# It is currently is not possible to retire an id with name X |
99 | | -# and add a new unretired property with name X. |
100 | | -# Confused? Here is the regression test: |
101 | | -# |
102 | | -# self.assertRaises(ValueError, self.db.user.create) |
| 97 | +# Changed to 1.56 |
103 | 98 | # |
104 | | -# newid = self.db.user.create(username="spam") |
105 | | -# self.assertEqual(self.db.user.lookup('spam'), newid) |
106 | | -# self.db.commit() |
107 | | -# self.assertEqual(self.db.user.lookup('spam'), newid) |
108 | | -# self.db.user.retire(newid) |
109 | | -# self.assertRaises(KeyError, self.db.user.lookup, 'spam') |
| 99 | +# 13 worked-around a current metakit bug, so retiring properties now |
| 100 | +# works correctly. |
| 101 | +# metakit 2.9.2 has a bug when using "find" on ordered views, |
| 102 | +# using multiple arguments for find doesn't work. |
110 | 103 | # |
111 | | -# # use the key again now that the old is retired (metakit FAILS!!) |
112 | | -# newid2 = self.db.user.create(username="spam") |
113 | | -# self.assertNotEqual(newid, newid2) |
114 | | -# # try to restore old node. this shouldn't succeed! |
115 | | -# self.assertRaises(KeyError, self.db.user.restore, newid) |
116 | | -# |
117 | | -# self.assertRaises(TypeError, self.db.issue.lookup, 'fubar') |
| 104 | +# Known Current Bugs: |
| 105 | +# You can't change a class' key properly. |
| 106 | +# This shouldn't be too hard to fix. |
118 | 107 | # |
119 | 108 |
|
120 | 109 | from roundup import hyperdb, date, password, roundupdb, security |
@@ -475,7 +464,7 @@ def get(self, nodeid, propname, default=_marker, cache=1): |
475 | 464 | ''' |
476 | 465 | 'cache' exists for backwards compatibility, and is not used. |
477 | 466 | ''' |
478 | | - view = self.getview() |
| 467 | + view = self.getview() |
479 | 468 | id = int(nodeid) |
480 | 469 | if cache == 0: |
481 | 470 | oldnode = self.uncommitted.get(id, None) |
@@ -784,9 +773,13 @@ def retire(self, nodeid): |
784 | 773 | self.db.addjournal(self.classname, nodeid, _RETIRE, {}) |
785 | 774 | if self.key: |
786 | 775 | iv = self.getindexview(READWRITE) |
787 | | - ndx = iv.find(k=getattr(row, self.key),i=row.id) |
788 | | - if ndx > -1: |
| 776 | + ndx = iv.find(k=getattr(row, self.key)) |
| 777 | + # find is broken with multiple attribute lookups |
| 778 | + # on ordered views |
| 779 | + #ndx = iv.find(k=getattr(row, self.key),i=row.id) |
| 780 | + if ndx > -1 and iv[ndx].i == row.id: |
789 | 781 | iv.delete(ndx) |
| 782 | + |
790 | 783 | self.db.dirty = 1 |
791 | 784 | self.fireReactors('retire', nodeid, None) |
792 | 785 |
|
|
0 commit comments