comparison roundup/backends/back_anydbm.py @ 2600:f25ff5a05abd

anydbm fixes: - Remove duplicate call to indexer - Remove defaulting of props to None unnecessarily -- masks get() with default values.
author Richard Jones <richard@users.sourceforge.net>
date Tue, 20 Jul 2004 07:26:40 +0000
parents c86b2179085b
children 113548baeed2
comparison
equal deleted inserted replaced
2597:c86b2179085b 2600:f25ff5a05abd
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.161 2004-07-20 05:57:54 richard Exp $ 18 #$Id: back_anydbm.py,v 1.162 2004-07-20 07:26:40 richard Exp $
19 '''This module defines a backend that saves the hyperdatabase in a 19 '''This module defines a backend that saves the hyperdatabase in a
20 database chosen by anydbm. It is guaranteed to always be available in python 20 database chosen by anydbm. It is guaranteed to always be available in python
21 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several 21 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
22 serious bugs, and is not available) 22 serious bugs, and is not available)
23 ''' 23 '''
894 continue 894 continue
895 if key == self.key: 895 if key == self.key:
896 raise ValueError, 'key property "%s" is required'%key 896 raise ValueError, 'key property "%s" is required'%key
897 if isinstance(prop, Multilink): 897 if isinstance(prop, Multilink):
898 propvalues[key] = [] 898 propvalues[key] = []
899 else:
900 propvalues[key] = None
901 899
902 # done 900 # done
903 self.db.addnode(self.classname, newid, propvalues) 901 self.db.addnode(self.classname, newid, propvalues)
904 if self.do_journal: 902 if self.do_journal:
905 self.db.addjournal(self.classname, newid, 'create', {}) 903 self.db.addjournal(self.classname, newid, 'create', {})
2056 mime_type = propvalues.get('type', self.default_mime_type) 2054 mime_type = propvalues.get('type', self.default_mime_type)
2057 2055
2058 # do the database create 2056 # do the database create
2059 newid = self.create_inner(**propvalues) 2057 newid = self.create_inner(**propvalues)
2060 2058
2061 # and index!
2062 self.db.indexer.add_text((self.classname, newid, 'content'), content,
2063 mime_type)
2064
2065 # fire reactors 2059 # fire reactors
2066 self.fireReactors('create', newid, None) 2060 self.fireReactors('create', newid, None)
2067 2061
2068 # store off the content as a file 2062 # store off the content as a file
2069 self.db.storefile(self.classname, newid, None, content) 2063 self.db.storefile(self.classname, newid, None, content)

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