Django REST framework views using the pipeline pattern.
Project description
Django REST Framework Pipeline Views
pip install drf-pipeline-views
Documentation: https://mrthearman.github.io/drf-pipeline-views/
Source Code: https://github.com/MrThearMan/drf-pipeline-views/
Inspired by a talk on The Clean Architecture in Python by Brandon Rhodes, drf-pipeline-views aims to simplify writing testable API endpoints with Django REST framework using the Pipeline Design Pattern.
The main idea behind the pipeline pattern is to process data in steps. Input from the previous step is passed to the next, resulting in a collection of "data-in, data-out" -functions. These functions can be easily unit tested, since none of the functions depend on the state of the objects in the other parts of the pipeline. Furthermore, IO can be separated into its own step, making the other parts of the logic simpler and faster to test by not having to mock or do any other special setup around the IO. This also means that the IO block, or in fact any other part of the application, can be replaced as long as the data flowing through the pipeline remains the same.
from pipeline_views import BasePipelineView, GetMixin
from .my_serializers import InputSerializer, OutputSerializer
from .my_validators import validator
from .my_services import io_func, logging_func, integration_func
class SomeView(GetMixin, BasePipelineView):
pipelines = {
"GET": [
InputSerializer,
validator,
io_func,
integration_func,
logging_func,
OutputSerializer,
],
}
Have a look at the quickstart section in the documentation on basic usage.
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
File details
Details for the file drf-pipeline-views-0.6.0.tar.gz
.
File metadata
- Download URL: drf-pipeline-views-0.6.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.12 Linux/5.13.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6571bf29f41606f3d3edde28eb5b269d586366547306e69f492cfd9aafc2ccd |
|
MD5 | 16822cdecdbb2844093273592b3e609c |
|
BLAKE2b-256 | d061d13d0622fecd31e0a7598c765db6ee0dc935fbe36f054094c35794ad1a2d |
File details
Details for the file drf_pipeline_views-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: drf_pipeline_views-0.6.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.12 Linux/5.13.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76a3b1fcc36b1312f4840c55ebb5246a34544b47a825136dbf461157178316a2 |
|
MD5 | 9f79d512060dce8e75d3ff059e56a3a2 |
|
BLAKE2b-256 | 7e01be8b59c1f506de467867759daf8bfd5a6f39642b386ef0d6a06bffa10ba8 |