Socket
Socket
Sign inDemoInstall

ckantools

Package Overview
Dependencies
10
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ckantools

Utilities for ckan extensions.


Maintainers
1

Readme

ckantools

CKAN Python

Utilities and common methods for CKAN extensions.

Overview

A collection of methods, decorators, and anything else that might be useful.

ckantools is still very much in development, and is prone to frequent changes that may or may not work.

Installation

pip install ckantools

Usage

See the full usage docs on readthedocs.io.

Actions

Use the @action decorator to add actions:

# logic/actions/module_name.py

from ckantools.decorators import action

@action(schema, helptext, get=False, *other_decorators)
def example_action(parameter_1, parameter_2):
    # ...

Or the @basic_action decorator if you want to load the action but don't want any of the other features (schema loading, auto auth, etc):

from ckantools.decorators import basic_action

@basic_action
def example_action(context, data_dict):
    # ...

And then load the action(s) in plugin.py:

# plugin.py

from .logic.actions import module_name
from ckantools.loaders import create_actions
from ckan.plugins import implements, interfaces, SingletonPlugin

class ExamplePlugin(SingletonPlugin):
    implements(interfaces.IActions)

    # IActions
    def get_actions(self):
        return create_actions(module_name)

Auth

Loading auth functions is similar to actions, i.e. use the @auth decorator.

# logic/auth/module_name.py

from ckantools.decorators import auth

@auth(anon=True)
def example_action(context, data_dict):
    return {'success': True}

@auth('example_action')
def other_action(context, data_dict):
    # checks access to example_action first
    return {'success': True}

The auth functions can then be loaded in plugin.py:

# plugin.py

from .logic.auth import module_name
from ckantools.loaders import create_auth
from ckan.plugins import implements, interfaces, SingletonPlugin

class ExamplePlugin(SingletonPlugin):
    implements(interfaces.IActions)

    # IAuthFunctions
    def get_auth_functions(self):
        return create_auth(module_name)

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc