ckanext-bulk
An extension that helps to perform bulk operations over CKAN entities, such as datasets, resources, organizations and groups.
Interface
The extension provides an IBulk interface that allows you to register custom entity managers or override the default ones.
By default the extension provides entity managers for datasets, resources, organizations and groups. You might have some custom
entities on your CKAN portal, or some specific logic for the existing ones.
Here's how to register a custom entity manager:
import ckan.plugins as p
from ckanext.bulk.interfaces import IBulk
from ckanext.bulk.entity_managers import base, DatasetEntityManager
class CustomDatasetEntityManager(DatasetEntityManager):
"""Custom implementation of the DatasetEntityManager."""
entity_type = "dataset"
@classmethod
def get_fields(cls) -> list[base.FieldItem]:
# Override to add custom fields
fields = super().get_fields()
fields.extend([
base.FieldItem(value="custom_field", text="Custom Field")
])
return fields
@classmethod
def search_entities_by_filters(
cls, filters: list[base.FilterItem], global_operator: str = const.GLOBAL_AND
) -> list[dict[str, Any]]:
# Implement custom search logic
return super().search_entities_by_filters(filters, global_operator)
class CustomBulk(p.SingletonPlugin):
p.implements(IBulk, inherit=True)
def register_entity_manager(
self, entity_managers: dict[str, type[base.EntityManager]]
):
# Register your custom entity manager
entity_managers[CustomDatasetEntityManager.entity_type] = CustomDatasetEntityManager
return entity_managers
The interface allows you to:
- Create custom entity managers by extending base managers (
DatasetEntityManager,GroupEntityManager, etc.) or creating your own. - Override default entity managers with your own implementations
Your entity manager should implement these key methods:
get_fields(): Returns available fields for the entitysearch_entities_by_filters(): Implements search logicupdate_entity(): Handles entity updatesdelete_entity(): Handles entity deletion
CSV export
The extension provides a way to export data to CSV.
You can implement the IBulk interface and override the prepare_csv_data() method to prepare the data for export.
The method should return a list of dictionaries, the keys will be used as a header in the CSV file.
Data for search results and logs are stored in redis, and expire after 1 hour. This method will be called before the data is stored in redis, so we can reduce the amount of data to store in redis.
The export_type parameter can be "result" or "logs".
Example of how to override the prepare_csv_data() method:
class CustomBulk(p.SingletonPlugin):
p.implements(IBulk, inherit=True)
def prepare_csv_data(
self,
data: list[dict[str, Any]],
export_type: str,
entity_type: str | None = None,
) -> list[dict[str, Any]]:
# Implement custom logic to prepare the data for export
return data
Requirements
Compatibility with core CKAN versions:
| CKAN version | Compatible? |
|---|---|
| 2.9 | no |
| 2.10 | yes |
| 2.11 | yes |
| master | not tested |
Metadata
Release files for ckanext-bulk 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ckanext_bulk-0.4.0.tar.gz | 106.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ckanext_bulk-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 221.5 kB
Release files / ckanext_bulk-0.4.0.tar.gz
| Download URL | ckanext_bulk-0.4.0.tar.gz |
|---|---|
| Size | 106.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d98f13eb73866110dc711ab12032e8c697cec2623db763c0d06d095cb7dd0370
|
|
BLAKE2b-256 checksum How to use checksums |
e7dcb2c7162dbf030ab484939d2bf3a9602b5fccd7c74fe4357dc4b415d4f9c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.4
|
Release files / ckanext_bulk-0.4.0-py3-none-any.whl
| Download URL | ckanext_bulk-0.4.0-py3-none-any.whl |
|---|---|
| Size | 115.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
367d8d655ebf75d8602661d5f4e0e41698f1653aa8d742c623631881c69170c1
|
|
BLAKE2b-256 checksum How to use checksums |
82a4ad9e239fc505c22f26249d5da2ca528ec062619b39091676e22261a5784c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.4
|
Security for ckanext-bulk 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.