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


Python toolkit.asbool方法代码示例

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


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

示例1: group_create

# 需要导入模块: from ckan.plugins import toolkit [as 别名]
# 或者: from ckan.plugins.toolkit import asbool [as 别名]
def group_create(context, data_dict=None):

    # Get the value of the ckan.iauthfunctions.users_can_create_groups
    # setting from the CKAN config file as a string, or False if the setting
    # isn't in the config file.
    users_can_create_groups = config.get(
        'ckan.iauthfunctions.users_can_create_groups', False)

    # Convert the value from a string to a boolean.
    users_can_create_groups = toolkit.asbool(users_can_create_groups)

    if users_can_create_groups:
        return {'success': True}
    else:
        return {'success': False,
                'msg': 'Only sysadmins can create groups'} 
开发者ID:italia,项目名称:daf-recipes,代码行数:18,代码来源:plugin_v5_custom_config_setting.py

示例2: show_most_popular_groups

# 需要导入模块: from ckan.plugins import toolkit [as 别名]
# 或者: from ckan.plugins.toolkit import asbool [as 别名]
def show_most_popular_groups():
    '''Return the value of the most_popular_groups config setting.

    To enable showing the most popular groups, add this line to the
    [app:main] section of your CKAN config file::

      ckan.example_theme.show_most_popular_groups = True

    Returns ``False`` by default, if the setting is not in the config file.

    :rtype: boolean

    '''
    value = config.get('ckan.example_theme.show_most_popular_groups', False)
    value = toolkit.asbool(value)
    return value 
开发者ID:italia,项目名称:daf-recipes,代码行数:18,代码来源:plugin.py

示例3: harvest_source_index_clear

# 需要导入模块: from ckan.plugins import toolkit [as 别名]
# 或者: from ckan.plugins.toolkit import asbool [as 别名]
def harvest_source_index_clear(context, data_dict):
    '''
    Clears all datasets, jobs and objects related to a harvest source, but
    keeps the source itself.  This is useful to clean history of long running
    harvest sources to start again fresh.

    :param id: the id of the harvest source to clear
    :type id: string
    '''

    check_access('harvest_source_clear', context, data_dict)
    harvest_source_id = data_dict.get('id')

    source = HarvestSource.get(harvest_source_id)
    if not source:
        log.error('Harvest source %s does not exist', harvest_source_id)
        raise NotFound('Harvest source %s does not exist' % harvest_source_id)

    harvest_source_id = source.id

    conn = make_connection()
    query = ''' +%s:"%s" +site_id:"%s" ''' % (
        'harvest_source_id', harvest_source_id, config.get('ckan.site_id'))

    solr_commit = toolkit.asbool(config.get('ckan.search.solr_commit', 'true'))
    if toolkit.check_ckan_version(max_version='2.5.99'):
        # conn is solrpy
        try:
            conn.delete_query(query)
            if solr_commit:
                conn.commit()
        except Exception, e:
            log.exception(e)
            raise SearchIndexError(e)
        finally: 
开发者ID:italia,项目名称:daf-recipes,代码行数:37,代码来源:update.py

示例4: before_show

# 需要导入模块: from ckan.plugins import toolkit [as 别名]
# 或者: from ckan.plugins.toolkit import asbool [as 别名]
def before_show(self, resource_dict):
        resource_dict[
            'datastore_contains_all_records_of_source_file'] = toolkit.asbool(
            resource_dict.get('datastore_contains_all_records_of_source_file'))

    # IConfigurer 
开发者ID:ckan,项目名称:ckanext-xloader,代码行数:8,代码来源:plugin.py

示例5: configure

# 需要导入模块: from ckan.plugins import toolkit [as 别名]
# 或者: from ckan.plugins.toolkit import asbool [as 别名]
def configure(self, config):
        """
        Called upon CKAN setup, will pass current configuration dict
        to the plugin to read custom options.
        """
        discourse_url = config.get('discourse.url', None)
        discourse_username = config.get('discourse.username', None)
        discourse_count_cache_age = config.get('discourse.count_cache_age', 60)
        discourse_ckan_category = config.get('discourse.ckan_category', None)
        discourse_debug = asbool(config.get('discourse.debug', False))

        if discourse_url is None:
            log.warn("No discourse forum name is set. Please set \
            'discourse.url' in your .ini!")
        else:
            discourse_url = discourse_url.rstrip('/') + '/'

        if discourse_ckan_category is None:
            log.warn("Discourse needs discourse.ckan_category set to work. Please set \
            'discourse.ckan_category' in your .ini!")

        # check for valid JSON
        try:
            discourse_api = discourse_url + discourse_ckan_category + '.json'
            r = requests.get(discourse_api, verify=False)
            test_category_dict = r.json()
        except:
            log.warn(discourse_api + " is not a valid Discourse JSON endpoint!")

        config['pylons.app_globals'].has_commenting = True

        # store these so available to class methods
        self.__class__.discourse_url = discourse_url
        self.__class__.discourse_username = discourse_username
        self.__class__.discourse_count_cache_age = discourse_count_cache_age
        self.__class__.discourse_ckan_category = discourse_ckan_category
        self.__class__.discourse_debug = discourse_debug
        self.__class__.next_sync = time.time() + discourse_count_cache_age
        self.__class__.topic_lookup_dict = {}
        self.__class__.active_conversations = 0
        self.__class__.discourse_sync()


    # IConfigurer 
开发者ID:OpenGov-OpenData,项目名称:ckanext-discourse,代码行数:46,代码来源:plugin.py


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