def open(self, dbspec): ObjectDatabase.open(self, dbspec) # increase the maximum number of objects cached #site_config = get_config() #size = site_config.get(self.site, 'object-cache-size', fallback='50000') size=200000 self.set_cache_size(size)
if __name__ == '__main__': usage = "usage: %prog [options]" parser = OptionParser(usage) parser.add_option('-d', '--database', dest='database', default='file:data/canary_db', help='path to database file', metavar='FILE') parser.add_option('-c', '--config', dest='config', default='conf/canary_config.py', help='path to configuration file') (options, args) = parser.parse_args() config = MyConfig() config.read_file(options.config) config.zodb_connection_string = 'file:%s' % options.database zodb = ObjectDatabase() sessions = zodb.open(config.zodb_connection_string) zodb_root = zodb.get_root() user_db = zodb_root['user_db'] try: for user in user_db.get_users(): print 'Updating user', user.get_id() user._p_changed = True get_transaction().commit() except: import traceback print traceback.print_exc() print 'Last user:', user.get_id() get_transaction().abort()
def __init__(self, site): ObjectDatabase.__init__(self) if site is None: site = os.environ.get('SITE', None) self.site = site