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


Python HarvestSource.id方法代码示例

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


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

示例1: _create_harvest_source_object

# 需要导入模块: from ckanext.harvest.model import HarvestSource [as 别名]
# 或者: from ckanext.harvest.model.HarvestSource import id [as 别名]
def _create_harvest_source_object(context, data_dict):
    '''
        Creates an actual HarvestSource object with the data dict
        of the harvest_source dataset. All validation and authorization
        checks should be used by now, so this function is not to be used
        directly to create harvest sources. The created harvest source will
        have the same id as the dataset.

        :param data_dict: A standard package data_dict

        :returns: The created HarvestSource object
        :rtype: HarvestSource object
    '''

    log.info('Creating harvest source: %r', data_dict)

    source = HarvestSource()

    source.id = data_dict['id']
    source.url = data_dict['url'].strip()
    source.catalogue_country=data_dict['catalogue_country']
    source.language=data_dict['language']
    source.catalogue_date_created=data_dict['catalogue_date_created']
    source.catalogue_date_updated=data_dict['catalogue_date_updated']
    # Avoids clashes with the dataset type
    source.type = data_dict['source_type']
    #source.country=data['country']	
    opt = ['active', 'title', 'description', 'user_id',
           'publisher_id', 'config', 'frequency']
    for o in opt:
        if o in data_dict and data_dict[o] is not None:
            source.__setattr__(o,data_dict[o])

    source.active = not data_dict.get('state', None) == 'deleted'

    # Don't commit yet, let package_create do it
    source.add()
    log.info('Harvest source created: %s', source.id)

    ##---------------save job to mongodb--------
    client=pymongo.MongoClient(str(mongoclient),int(mongoport))
    job={"cat_url":str(source.url),"type":str(source.type),"id":str(source.id),"description":str(source.description),"frequency":str(source.frequency),"title":str(source.title),'country':str(source.catalogue_country),'language':str(source.language),'catalogue_date_created':str(source.catalogue_date_created),'catalogue_date_updated':str(source.catalogue_date_updated)}
    db=client.odm
    collection=db.jobs
    collection.save(job)



    return source
开发者ID:traios,项目名称:HarvesterPlugins,代码行数:51,代码来源:plugin.py

示例2: _create_harvest_source_object

# 需要导入模块: from ckanext.harvest.model import HarvestSource [as 别名]
# 或者: from ckanext.harvest.model.HarvestSource import id [as 别名]
def _create_harvest_source_object(context, data_dict):
    '''
        Creates an actual HarvestSource object with the data dict
        of the harvest_source dataset. All validation and authorization
        checks should be used by now, so this function is not to be used
        directly to create harvest sources. The created harvest source will
        have the same id as the dataset.

        :param data_dict: A standard package data_dict

        :returns: The created HarvestSource object
        :rtype: HarvestSource object
    '''

    log.info('Creating harvest source: %r', data_dict)

    source = HarvestSource()

    source.id = data_dict['id']
    source.url = data_dict['url'].strip()

    # Avoids clashes with the dataset type
    source.type = data_dict['source_type']

    opt = ['active', 'title', 'description', 'user_id',
           'publisher_id', 'config', 'frequency']
    for o in opt:
        if o in data_dict and data_dict[o] is not None:
            source.__setattr__(o,data_dict[o])

    source.active = not data_dict.get('state', None) == 'deleted'

    # Don't commit yet, let package_create do it
    source.add()
    log.info('Harvest source created: %s', source.id)

    return source
开发者ID:geosolutions-it,项目名称:ckanext-harvest,代码行数:39,代码来源:plugin.py


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