Skip to main content

Django REST framework views using the pipeline pattern.

Project description

Django REST Framework Pipeline Views

Coverage Status Workflow Status PyPI Licence Last Commit Issues Downloads

Python Version Django Version DRF Version

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,
        ],
    }

Have a look at the quickstart section in the documentation on basic usage.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf_pipeline_views-0.9.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

drf_pipeline_views-0.9.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file drf_pipeline_views-0.9.1.tar.gz.

File metadata

  • Download URL: drf_pipeline_views-0.9.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1041-azure

File hashes

Hashes for drf_pipeline_views-0.9.1.tar.gz
Algorithm Hash digest
SHA256 8bdda89759615adc84a5872b7362d11befee47cd0bd3a8fbb9131f39314a01be
MD5 172fade54c6f47c072f7b32705745c86
BLAKE2b-256 7b4b1e4462fcec7ade5f39837cce6bcfedfc48c978c35f4a8ebd60b79f566898

See more details on using hashes here.

File details

Details for the file drf_pipeline_views-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: drf_pipeline_views-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1041-azure

File hashes

Hashes for drf_pipeline_views-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c58ea7809c11a95ba60004b0bed1d7e27e9cb87d44694756cd5fa3cf55222eee
MD5 a8c5c1ed551dda9be774766269f2ed11
BLAKE2b-256 88905fc1e665e61ee33754cca75f6ca2ce81491e3413f40888d062f10e6feabc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page