在OP的辩护中,文档看起来确实有点不透明.我一直在寻找这个,试图获得一个自定义的API动作来提供工作的JSON新闻源,最后想出了这个:
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
# Required so that GET requests work
@toolkit.side_effect_free
def get_news(context,data_dict=None):
# The actual custom API method
return {"hello":"world"}
class CustomAPIPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.interfaces.IActions)
def get_actions(self):
# Registers the custom API method defined above
return {'get_news': get_news}
Run Code Online (Sandbox Code Playgroud)
描述创建身份验证插件的教程如下:
http://docs.ckan.org/en/latest/extensions/tutorial.html#creating-a-new-extension
我所做的是抄袭,但使用IActions而不是IAuthFunctions:
http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html
它正在安装CKAN 2.2.1.
| 归档时间: |
|
| 查看次数: |
532 次 |
| 最近记录: |