Utilities for ckan extensions.
Project description
ckantools
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ckantools-0.5.0.tar.gz.
File metadata
- Download URL: ckantools-0.5.0.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
509a85fc033165a9dda772ea6ccd6df773164eb9fff91c292b31c851bf84e219
|
|
| MD5 |
b762b26208fc3deb33e25636f2118d25
|
|
| BLAKE2b-256 |
3e7c3761f846f2d8d38328d2de0004f1d719e2cbae144d16f80476c446bd4f76
|
File details
Details for the file ckantools-0.5.0-py3-none-any.whl.
File metadata
- Download URL: ckantools-0.5.0-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f7da052ece3246a34c232325490d8004cf9de98b9f949d08b9f149a7e24bd0
|
|
| MD5 |
e2de0149e09274db27828b8904042745
|
|
| BLAKE2b-256 |
ebda41d9a9527e32858b2bf06fdc18b84bcc3402dd25759afd6371a58aa092f3
|