本文整理匯總了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