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 BaseAPIView, 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, BaseAPIView):

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drf_pipeline_views-0.3.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: drf-pipeline-views-0.3.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.10 Linux/5.11.0-1028-azure

File hashes

Hashes for drf-pipeline-views-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a30792e9ca4f0d0e2cf9b1cb6e787483669a5deda41a4adc31563f055650beb8
MD5 e950a6e745c9d4e7a8bfb2444b6368a8
BLAKE2b-256 fa95198fd9ceb063762a69a6e22b13cc272d574a08d9f9105b2b3acc6a2b12ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: drf_pipeline_views-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.10 Linux/5.11.0-1028-azure

File hashes

Hashes for drf_pipeline_views-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7b1af8823d1d62afaea500009c3b8b6c5c56593f1e4b3112c5006e8575f4a2f
MD5 2ecec9a56da22418459cdf2fd776d6ee
BLAKE2b-256 5b4a7b52d73257b5f9bb6d8df7dc014c40091abcd4bd0cabe1b9966942dde61d

See more details on using hashes here.

Supported by

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