def test_overriddenConfigValue(self): dbConfig = db.init_config_show(model) assert 'ngds.publish' in dbConfig assert 'ngds.harvest' in dbConfig assert 'ngds.edit_metadata' in dbConfig assert json.dumps(dbConfig['ngds.publish']).strip('"') == 'True' assert json.dumps(dbConfig['ngds.harvest']).strip('"') == 'True' assert json.dumps(dbConfig['ngds.edit_metadata']).strip('"') == 'True'
def update_config(self, config): """ Use this function to hook into the pylons global config object before the server starts up. The call to read configurations from the 'ngds_system_info' table happens after they are read from the vanilla CKAN 'system_info' table, therefore ensuring that custom configurations get used over vanilla ones. @config: Pylons global config object """ # Register ngds admin configurations with pylons app_globals.mappings['ngds.publish'] = 'ngds.publish' app_globals.mappings['ngds.harvest'] = 'ngds.harvest' app_globals.mappings['ngds.edit_metadata'] = 'ngds.edit_metadata' app_globals.mappings['ngds.featured_data'] = 'ngds.featured_data' # Collect config data to populate 'ngds_system_info' table if this is # the first time this server is booting up with the 'sysadmin' plugin. # Initially, this table will be populated with either what it finds in # the config file or default values. data = { 'ngds.publish': config.get('ngds.publish', 'True'), 'ngds.harvest': config.get('ngds.harvest', 'True'), 'ngds.edit_metadata': config.get('ngds.edit_metadata', 'True'), 'ngds.featured_data': config.get('ngds.featured_data', None) } # If this is the first time booting up the server with the 'sysadmin' # plugin, then build the 'ngds_system_info' table, populate it with the # default values and build ORM. Otherwise, just build the ORM. db.init_table_populate(model, data) # Always read the 'ngds_system_info' table upon starting the server db_config = db.init_config_show(model) # Update pylons global config object with the configs we just read from # the 'ngds_system_info' table. config.update(db_config) # Add custom templates directory p.toolkit.add_template_directory(config, 'templates') # Add public assets directory p.toolkit.add_public_directory(config, 'public') # Register fanstatic directory for JavaScript files p.toolkit.add_resource('fanstatic', 'sysadmin')