Skip to main content

Набор компонентов для интеграции explicit с django

Project description

Explicit-Django

Набор компонентов для интеграции Explicit с Django.

Базовая единица работы на транзакциях Django ORM.

# persons/core/unit_of_work.py

from explicit.django.unit_of_work import BaseUnitOfWork

from persons.core.persons.adapters.db import Repository as PersonsRepository
from persons.core.persons.adapters.db import repository as persons_repository

# (имя атрибута, инстанс репо)
KNOWN_REPOS = (
    ('persons', persons_repository),
)


class UnitOfWork(BaseUnitOfWork):

    persons: PersonsRepository

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._registry.register(*KNOWN_REPOS)

Декоратор для преобразования ошибок валидации предметной области в ошибки валидации Django

from explicit.django.domain.validation.exceptions import handle_domain_validation_error

class ViewSet(...):

   @handle_domain_validation_error
   def create(self, request, *args, **kwargs):
       command = Command(...)
       bus.handle(command)

Запуск тестов

$ tox

e30984f (EDUEO-552 Вынос интеграции с django в отдельный пакет.)

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

explicit_python_django-1.0.1.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

explicit_python_django-1.0.1-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

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