comparison roundup/backends/back_anydbm.py @ 1304:61ad556cfc8d

working toward 0.5.2 release
author Richard Jones <richard@users.sourceforge.net>
date Wed, 06 Nov 2002 11:38:43 +0000
parents 71be6588904f
children d034cb5929e6
comparison
equal deleted inserted replaced
1303:71be6588904f 1304:61ad556cfc8d
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 #$Id: back_anydbm.py,v 1.91 2002-11-06 05:39:49 richard Exp $ 18 #$Id: back_anydbm.py,v 1.92 2002-11-06 11:38:42 richard Exp $
19 ''' 19 '''
20 This module defines a backend that saves the hyperdatabase in a database 20 This module defines a backend that saves the hyperdatabase in a database
21 chosen by anydbm. It is guaranteed to always be available in python 21 chosen by anydbm. It is guaranteed to always be available in python
22 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several 22 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
23 serious bugs, and is not available) 23 serious bugs, and is not available)
886 propvalues[key] = None 886 propvalues[key] = None
887 887
888 # done 888 # done
889 self.db.addnode(self.classname, newid, propvalues) 889 self.db.addnode(self.classname, newid, propvalues)
890 if self.do_journal: 890 if self.do_journal:
891 self.db.addjournal(self.classname, newid, 'create', propvalues) 891 self.db.addjournal(self.classname, newid, 'create', {})
892 892
893 self.fireReactors('create', newid, None) 893 self.fireReactors('create', newid, None)
894 894
895 return newid 895 return newid
896 896
968 del d['creation'] 968 del d['creation']
969 else: 969 else:
970 creation = None 970 creation = None
971 if d.has_key('activity'): 971 if d.has_key('activity'):
972 del d['activity'] 972 del d['activity']
973 self.db.addjournal(self.classname, newid, 'create', d, creator, 973 self.db.addjournal(self.classname, newid, 'create', {}, creator,
974 creation) 974 creation)
975 return newid 975 return newid
976 976
977 def get(self, nodeid, propname, default=_marker, cache=1): 977 def get(self, nodeid, propname, default=_marker, cache=1):
978 '''Get the value of a property on an existing node of this class. 978 '''Get the value of a property on an existing node of this class.
1143 raise KeyError, '"%s" has no property named "%s"'%( 1143 raise KeyError, '"%s" has no property named "%s"'%(
1144 self.classname, propname) 1144 self.classname, propname)
1145 1145
1146 # if the value's the same as the existing value, no sense in 1146 # if the value's the same as the existing value, no sense in
1147 # doing anything 1147 # doing anything
1148 if node.has_key(propname) and value == node[propname]: 1148 current = node.get(propname, None)
1149 if value == current:
1149 del propvalues[propname] 1150 del propvalues[propname]
1150 continue 1151 continue
1152 journalvalues[propname] = current
1151 1153
1152 # do stuff based on the prop type 1154 # do stuff based on the prop type
1153 if isinstance(prop, Link): 1155 if isinstance(prop, Link):
1154 link_class = prop.classname 1156 link_class = prop.classname
1155 # if it isn't a number, it's a key 1157 # if it isn't a number, it's a key
1281 1283
1282 # do the set, and journal it 1284 # do the set, and journal it
1283 self.db.setnode(self.classname, nodeid, node) 1285 self.db.setnode(self.classname, nodeid, node)
1284 1286
1285 if self.do_journal: 1287 if self.do_journal:
1286 propvalues.update(journalvalues) 1288 self.db.addjournal(self.classname, nodeid, 'set', journalvalues)
1287 self.db.addjournal(self.classname, nodeid, 'set', propvalues)
1288 1289
1289 self.fireReactors('set', nodeid, oldvalues) 1290 self.fireReactors('set', nodeid, oldvalues)
1290 1291
1291 return propvalues 1292 return propvalues
1292 1293
1610 filterspec = l 1611 filterspec = l
1611 1612
1612 # now, find all the nodes that are active and pass filtering 1613 # now, find all the nodes that are active and pass filtering
1613 l = [] 1614 l = []
1614 cldb = self.db.getclassdb(cn) 1615 cldb = self.db.getclassdb(cn)
1615 print filterspec
1616 try: 1616 try:
1617 # TODO: only full-scan once (use items()) 1617 # TODO: only full-scan once (use items())
1618 for nodeid in self.db.getnodeids(cn, cldb): 1618 for nodeid in self.db.getnodeids(cn, cldb):
1619 node = self.db.getnode(cn, nodeid, cldb) 1619 node = self.db.getnode(cn, nodeid, cldb)
1620 if node.has_key(self.db.RETIRED_FLAG): 1620 if node.has_key(self.db.RETIRED_FLAG):

Roundup Issue Tracker: http://roundup-tracker.org/