当前位置: 首页>>代码示例>>Python>>正文


Python pylons.config方法代码示例

本文整理汇总了Python中pylons.config方法的典型用法代码示例。如果您正苦于以下问题:Python pylons.config方法的具体用法?Python pylons.config怎么用?Python pylons.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylons的用法示例。


在下文中一共展示了pylons.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_class

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def setup_class(cls):

        if not pylons.config.get('ckan.datastore.read_url'):
            raise nose.SkipTest('Datastore runs on legacy mode, skipping...')

        engine = db._get_engine(
            {'connection_url': pylons.config['ckan.datastore.write_url']}
        )
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))

        datastore_test_helpers.clear_db(cls.Session)

        create_tables = [
            u'CREATE TABLE test_a (id_a text)',
            u'CREATE TABLE test_b (id_b text)',
            u'CREATE TABLE "TEST_C" (id_c text)',
            u'CREATE TABLE test_d ("?/?" integer)',
        ]
        for create_table_sql in create_tables:
            cls.Session.execute(create_table_sql) 
开发者ID:namgk,项目名称:ckan-timeseries,代码行数:22,代码来源:test_helpers.py

示例2: test_clear_works

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_clear_works(self):

        # Keep a copy of the original Pylons config
        _original_pylons_config = pylons.config.copy()

        my_conf = CKANConfig()

        my_conf[u'test_key_1'] = u'Test value 1'
        my_conf[u'test_key_2'] = u'Test value 2'

        eq_(len(my_conf.keys()), 2)

        my_conf.clear()

        eq_(len(my_conf.keys()), 0)

        # Restore Pylons config
        pylons.config.update(_original_pylons_config) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:20,代码来源:test_common.py

示例3: test_read_private

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_read_private(self):
        context = {
            'user': self.sysadmin_user.name,
            'model': model}
        data_dict = {
            'resource_id': self.data['resource_id'],
            'connection_url': pylons.config['ckan.datastore.write_url']}
        p.toolkit.get_action('datastore_ts_make_private')(context, data_dict)
        query = 'SELECT * FROM "{0}"'.format(self.data['resource_id'])
        data = {'sql': query}
        postparams = json.dumps(data)
        auth = {'Authorization': str(self.normal_user.apikey)}
        res = self.app.post('/api/action/datastore_ts_search_sql', params=postparams,
                            extra_environ=auth, status=403)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is False
        assert res_dict['error']['__type'] == 'Authorization Error'

        # make it public for the other tests
        p.toolkit.get_action('datastore_ts_make_public')(context, data_dict) 
开发者ID:namgk,项目名称:ckan-timeseries,代码行数:22,代码来源:test_search.py

示例4: download_and_extract

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def download_and_extract(resource_url):
    """
    Download resource and extract metadata using Solr.

    The extracted metadata is cleaned and returned.
    """
    session = Session()
    request = Request('GET', resource_url).prepare()
    for plugin in PluginImplementations(IExtractorRequest):
        request = plugin.extractor_before_request(request)
    with tempfile.NamedTemporaryFile() as f:
        r = session.send(request, stream=True)
        r.raise_for_status()
        for chunk in r.iter_content(chunk_size=1024):
            f.write(chunk)
        f.flush()
        f.seek(0)
        data = pysolr.Solr(config['solr_url']).extract(f, extractFormat='text')
    data['metadata']['fulltext'] = data['contents']
    return dict(clean_metadatum(*x) for x in data['metadata'].iteritems()) 
开发者ID:stadt-karlsruhe,项目名称:ckanext-extractor,代码行数:22,代码来源:lib.py

示例5: test_new

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_new(self, lc_mock, dae_mock):
        """
        Metadata extraction without previous metadata.
        """
        res_dict = factories.Resource(**RES_DICT)
        get_metadata(res_dict).delete().commit()
        extract(config['__file__'], res_dict)
        metadata = get_metadata(res_dict)
        assert_equal(metadata.meta['fulltext'], METADATA['fulltext'],
                     'Wrong fulltext.')
        assert_equal(metadata.meta['author'], METADATA['author'],
                     'Wrong author.')
        assert_false('created' in metadata.meta,
                     '"created" field was not ignored.')
        assert_equal(metadata.last_format, res_dict['format'],
                     'Wrong last_format')
        assert_equal(metadata.last_url, res_dict['url'], 'Wrong last_url.')
        assert_true(metadata.task_id is None, 'Unexpected task ID.')
        assert_time_span(metadata.last_extracted, max=5)
        assert_package_found(METADATA['fulltext'], res_dict['package_id'],
                             'Metadata not indexed.')
        assert_package_found(METADATA['author'], res_dict['package_id'],
                             'Metadata not indexed.')
        assert_package_not_found(METADATA['created'], res_dict['package_id'],
                                 'Wrong metadata indexed.') 
开发者ID:stadt-karlsruhe,项目名称:ckanext-extractor,代码行数:27,代码来源:test_tasks.py

示例6: _load_plugin

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def _load_plugin(plugin):
    '''Add the given plugin to the ckan.plugins config setting.

    This is for functional tests that need the plugin to be loaded.
    Unit tests shouldn't need this.

    If the given plugin is already in the ckan.plugins setting, it won't be
    added a second time.

    :param plugin: the plugin to add, e.g. ``datastore``
    :type plugin: string

    '''
    plugins = set(config['ckan.plugins'].strip().split())
    plugins.add(plugin.strip())
    config['ckan.plugins'] = ' '.join(plugins) 
开发者ID:aptivate,项目名称:ckanext-datasetthumbnail,代码行数:18,代码来源:helpers.py

示例7: get_dataset_types_w_classification

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def get_dataset_types_w_classification():
    types = config['scheming.dataset_schemas']
    type_list = []
    for type in types.split():
        type = re.sub(r'.*?\:(.*?).json', r'\1', type)
        type_list.append(type)

    type_w_classification_list = []
    for t in type_list:
        f = _get_classfication_field(t)
        if f:
            type_w_classification_list.append(t)
    return type_w_classification_list 
开发者ID:abgov,项目名称:ckanext-classification,代码行数:15,代码来源:helpers.py

示例8: load_environment

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    config = PylonsConfig()
    
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='mapofinnovation', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = mapofinnovation.lib.helpers
    
    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)
    

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from markupsafe import escape'])

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    
    return config 
开发者ID:AnanseGroup,项目名称:map-of-innovation,代码行数:39,代码来源:environment.py

示例9: _paster

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def _paster(cls, cmd, config_path_rel):
        config_path = os.path.join(config['here'], config_path_rel)
        cls._system('paster --plugin ckan %s --config=%s' % (cmd, config_path)) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:5,代码来源:test_csw_client.py

示例10: _start_ckan_server

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def _start_ckan_server(config_file=None):
        if not config_file:
            config_file = config['__file__']
        config_path = config_file
        import subprocess
        process = subprocess.Popen(['paster', 'serve', config_path])
        return process 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:9,代码来源:test_csw_client.py

示例11: test_setting_a_key_sets_it_on_pylons_config

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_setting_a_key_sets_it_on_pylons_config(self):

        ckan_config[u'ckan.site_title'] = u'Example title'
        eq_(pylons.config[u'ckan.site_title'], u'Example title') 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:6,代码来源:test_common.py

示例12: test_setting_a_key_sets_it_on_flask_config_if_app_context

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_setting_a_key_sets_it_on_flask_config_if_app_context(self):

        app = helpers._get_test_app()
        with app.flask_app.app_context():

            ckan_config[u'ckan.site_title'] = u'Example title'
            eq_(flask.current_app.config[u'ckan.site_title'], u'Example title') 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:9,代码来源:test_common.py

示例13: test_update_works_on_pylons_config

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_update_works_on_pylons_config(self):

        ckan_config[u'ckan.site_title'] = u'Example title'

        ckan_config.update({
            u'ckan.site_title': u'Example title 2',
            u'ckan.new_key': u'test'})

        eq_(pylons.config[u'ckan.site_title'], u'Example title 2')
        eq_(pylons.config[u'ckan.new_key'], u'test') 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:12,代码来源:test_common.py

示例14: test_update_works_on_flask_config

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_update_works_on_flask_config(self):

        app = helpers._get_test_app()
        with app.flask_app.app_context():

            ckan_config[u'ckan.site_title'] = u'Example title'

            ckan_config.update({
                u'ckan.site_title': u'Example title 2',
                u'ckan.new_key': u'test'})

            eq_(flask.current_app.config[u'ckan.site_title'], u'Example title 2')
            eq_(flask.current_app.config[u'ckan.new_key'], u'test') 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:15,代码来源:test_common.py

示例15: test_config_option_update_action_works_on_pylons

# 需要导入模块: import pylons [as 别名]
# 或者: from pylons import config [as 别名]
def test_config_option_update_action_works_on_pylons(self):
        params = {
            u'ckan.site_title': u'Example title action',
        }

        helpers.call_action(u'config_option_update', {}, **params)

        eq_(pylons.config[u'ckan.site_title'], u'Example title action') 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:10,代码来源:test_common.py


注:本文中的pylons.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。