當前位置: 首頁>>代碼示例>>Python>>正文


Python plugins.implements方法代碼示例

本文整理匯總了Python中ckan.plugins.implements方法的典型用法代碼示例。如果您正苦於以下問題:Python plugins.implements方法的具體用法?Python plugins.implements怎麽用?Python plugins.implements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ckan.plugins的用法示例。


在下文中一共展示了plugins.implements方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: can_validate

# 需要導入模塊: from ckan import plugins [as 別名]
# 或者: from ckan.plugins import implements [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.implements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。