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
from .my_serializers import InputSerializer, OutputSerializer
from .my_validators import validator
from .my_services import io_func, logging_func, integration_func
class SomeView(BasePipelineView):
pipelines = {
"GET": [
InputSerializer,
validator,
io_func,
integration_func,
logging_func,
OutputSerializer,
],
}
New in 0.6.0, mixin classes were removed, BasePiplineView adds view methods automatically based on pipeline definitions!
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.1.tar.gz
.
File metadata
- Download URL: drf-pipeline-views-0.6.1.tar.gz
- Upload date:
- Size: 15.8 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 | 32f9e23a9431c7511067055a28f79e47c306922b7a08fc5823f89aa881a3c699 |
|
MD5 | bb67f6142015468f61a6da55284d12fc |
|
BLAKE2b-256 | ad5a2b4412351d4c72ca043c0e3eb25e0dfa7ff967c581826d8b2b3f4a0a17a4 |
File details
Details for the file drf_pipeline_views-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: drf_pipeline_views-0.6.1-py3-none-any.whl
- Upload date:
- Size: 18.6 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 | 0509c9508496a98626a4965cc067e7ea8584ff96e2472eb0af49d3a70641298c |
|
MD5 | 6a8ae469b0553c9d7ef57d770f174f99 |
|
BLAKE2b-256 | f1fb444b9e48c459a432ddea8a7b874cfc1734b095fa2d9d57c2ae28648eca92 |