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


Python plugins.SingletonPlugin方法代码示例

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


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

示例1: can_validate

# 需要导入模块: from ckan import plugins [as 别名]
# 或者: from ckan.plugins import SingletonPlugin [as 别名]
def can_validate(self, context, data_dict):
        '''
        When implemented, this call can be used to control whether the
        data validation should take place or not on a specific resource.

        Implementations will receive a context object and the data_dict of
        the resource.

        If it returns False, the validation won't be performed, and if it
        returns True there will be a validation job started.

        Note that after this methods is called there are further checks
        performed to ensure the resource has one of the supported formats.
        This is controlled via the `ckanext.validation.formats` config option.

        Here is an example implementation:


        from ckan import plugins as p

        from ckanext.validation.interfaces import IDataValidation


        class MyPlugin(p.SingletonPlugin):

            p.implements(IDataValidation, inherit=True)

            def can_validate(self, context, data_dict):

                if data_dict.get('my_custom_field') == 'xx':
                    return False

                return True

        '''
        return True 
开发者ID:frictionlessdata,项目名称:ckanext-validation,代码行数:38,代码来源:interfaces.py


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