Skip to content

Instantly share code, notes, and snippets.

@kindly
Created May 16, 2012 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kindly/9f19fcda5871321335ec to your computer and use it in GitHub Desktop.
Save kindly/9f19fcda5871321335ec to your computer and use it in GitHub Desktop.
Overide logic function example
from ckan.plugins import implements, SingletonPlugin, IConfigurable, IActions
from ckan.logic.get import vocabulary_show
## override the logic function, just add for_view in the context
## this will only work for this 'vocabulary show' api call.
def my_vocabulary_show(context, data_dict):
context['for_view'] = True
return vocabulary_show(context, data_dict)
class YourExtension(SigletonPlugin):
implements(IActions, inherit=True)
## the IAction extension returns a dictionary of core actions it wants to override.
def get_actions():
return {'vocabulary_show': my_vocabulary_show}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment