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

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

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


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.6.4.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

drf_pipeline_views-0.6.4-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file drf-pipeline-views-0.6.4.tar.gz.

File metadata

  • Download URL: drf-pipeline-views-0.6.4.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1029-azure

File hashes

Hashes for drf-pipeline-views-0.6.4.tar.gz
Algorithm Hash digest
SHA256 a4ffa9a61b67149064c0b72c6c5ba2d3c9e01095f4235649ee879f168de44dda
MD5 e1e7472e6048b3f3f9ee7a6b8d64c9f1
BLAKE2b-256 6213b254f6528fe5097580c95eb8536ed642c0d7daa3fbe422dcc23c3e759fdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: drf_pipeline_views-0.6.4-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1029-azure

File hashes

Hashes for drf_pipeline_views-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bea28cc1a7ee3534c3cb1e5537c6d50b7d2926510dddbafbe00d500d009f9eeb
MD5 d87f522fb751be85d7226f036dc4d380
BLAKE2b-256 f9a9af3ddf163464f8a263906f8ffb2cc946498ce92b870e93c8f11caae5dcb3

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