ckantools


Nameckantools JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummaryUtilities for ckan extensions.
upload_time2023-12-04 11:43:47
maintainer
docs_urlNone
author
requires_python>=3.6
licenseGPL-3.0-or-later
keywords ckan data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!--header-start-->
<img src="https://data.nhm.ac.uk/images/nhm_logo.svg" align="left" width="150px" height="100px" hspace="40"/>

# ckantools

[![CKAN](https://img.shields.io/badge/ckan-2.9.5-orange.svg?style=flat-square)](https://github.com/ckan/ckan)
[![Python](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?style=flat-square)](https://www.python.org/)

_Utilities and common methods for CKAN extensions._

<!--header-end-->

# Overview

<!--overview-start-->
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._

<!--overview-end-->

# Installation

<!--installation-start-->
```shell
pip install ckantools
```

<!--installation-end-->

# Usage

See the full usage docs on [readthedocs.io](https://ckantools.readthedocs.io).

<!--usage-start-->
## Actions

Use the `@action` decorator to add actions:
```python
# 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):
```python
from ckantools.decorators import basic_action

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

And then load the action(s) in `plugin.py`:
```python
# 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.

```python
# 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`:
```python
# 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)
```

<!--usage-end-->

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ckantools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "CKAN,data",
    "author": "",
    "author_email": "Natural History Museum <data@nhm.ac.uk>",
    "download_url": "https://files.pythonhosted.org/packages/ec/01/b70106f081c551f2688f2413b9275966ab92905af7bd1b75737ba9d1ef22/ckantools-0.4.0.tar.gz",
    "platform": null,
    "description": "<!--header-start-->\n<img src=\"https://data.nhm.ac.uk/images/nhm_logo.svg\" align=\"left\" width=\"150px\" height=\"100px\" hspace=\"40\"/>\n\n# ckantools\n\n[![CKAN](https://img.shields.io/badge/ckan-2.9.5-orange.svg?style=flat-square)](https://github.com/ckan/ckan)\n[![Python](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?style=flat-square)](https://www.python.org/)\n\n_Utilities and common methods for CKAN extensions._\n\n<!--header-end-->\n\n# Overview\n\n<!--overview-start-->\nA collection of methods, decorators, and anything else that might be useful.\n\n_ckantools is still very much in development, and is prone to frequent changes that may or may not work._\n\n<!--overview-end-->\n\n# Installation\n\n<!--installation-start-->\n```shell\npip install ckantools\n```\n\n<!--installation-end-->\n\n# Usage\n\nSee the full usage docs on [readthedocs.io](https://ckantools.readthedocs.io).\n\n<!--usage-start-->\n## Actions\n\nUse the `@action` decorator to add actions:\n```python\n# logic/actions/module_name.py\n\nfrom ckantools.decorators import action\n\n@action(schema, helptext, get=False, *other_decorators)\ndef example_action(parameter_1, parameter_2):\n    # ...\n```\n\nOr 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):\n```python\nfrom ckantools.decorators import basic_action\n\n@basic_action\ndef example_action(context, data_dict):\n    # ...\n```\n\nAnd then load the action(s) in `plugin.py`:\n```python\n# plugin.py\n\nfrom .logic.actions import module_name\nfrom ckantools.loaders import create_actions\nfrom ckan.plugins import implements, interfaces, SingletonPlugin\n\nclass ExamplePlugin(SingletonPlugin):\n    implements(interfaces.IActions)\n\n    # IActions\n    def get_actions(self):\n        return create_actions(module_name)\n```\n\n## Auth\n\nLoading auth functions is similar to actions, i.e. use the `@auth` decorator.\n\n```python\n# logic/auth/module_name.py\n\nfrom ckantools.decorators import auth\n\n@auth(anon=True)\ndef example_action(context, data_dict):\n    return {'success': True}\n\n@auth('example_action')\ndef other_action(context, data_dict):\n    # checks access to example_action first\n    return {'success': True}\n```\n\nThe auth functions can then be loaded in `plugin.py`:\n```python\n# plugin.py\n\nfrom .logic.auth import module_name\nfrom ckantools.loaders import create_auth\nfrom ckan.plugins import implements, interfaces, SingletonPlugin\n\nclass ExamplePlugin(SingletonPlugin):\n    implements(interfaces.IActions)\n\n    # IAuthFunctions\n    def get_auth_functions(self):\n        return create_auth(module_name)\n```\n\n<!--usage-end-->\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "Utilities for ckan extensions.",
    "version": "0.4.0",
    "project_urls": {
        "changelog": "https://github.com/NaturalHistoryMuseum/ckantools/blob/main/CHANGELOG.md",
        "repository": "https://github.com/NaturalHistoryMuseum/ckantools"
    },
    "split_keywords": [
        "ckan",
        "data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bdec41defe9a8b5bd81fc6a621782661172821e66fcc3942905194cd242b1286",
                "md5": "f7c2b3000e3f84a0af15a3d56d1947e6",
                "sha256": "7ec59052920147ba608de5cd593c7638a2c96a15ef99e0d594db2d5912951903"
            },
            "downloads": -1,
            "filename": "ckantools-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7c2b3000e3f84a0af15a3d56d1947e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 25225,
            "upload_time": "2023-12-04T11:43:45",
            "upload_time_iso_8601": "2023-12-04T11:43:45.939789Z",
            "url": "https://files.pythonhosted.org/packages/bd/ec/41defe9a8b5bd81fc6a621782661172821e66fcc3942905194cd242b1286/ckantools-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec01b70106f081c551f2688f2413b9275966ab92905af7bd1b75737ba9d1ef22",
                "md5": "0d85b184f4396e475da4ef4a73dd810b",
                "sha256": "5da041ea5dc062bc58a29450de6918345ef654f9ddccb4c6af1d808573a5491b"
            },
            "downloads": -1,
            "filename": "ckantools-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0d85b184f4396e475da4ef4a73dd810b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 23452,
            "upload_time": "2023-12-04T11:43:47",
            "upload_time_iso_8601": "2023-12-04T11:43:47.703463Z",
            "url": "https://files.pythonhosted.org/packages/ec/01/b70106f081c551f2688f2413b9275966ab92905af7bd1b75737ba9d1ef22/ckantools-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-04 11:43:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NaturalHistoryMuseum",
    "github_project": "ckantools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ckantools"
}
        
Elapsed time: 0.15789s