No project description provided
Project description
Clean Architecture
This project is described a clean architecture written by Robert C. Martine. Architecture is fellow a clean architecture
Table of contents
DirectoryStructure
|-- clean_architecture | |-- domain | | |-request_object.py | | |-response_object.py | | `-use_case.py | |-- entity | | `-entity.py | |-- exception | | |-exception.py | | `- *_exception.py | |-- serializer | `-serializer.py
Installation
pip install clean-architecture
Example
- Entity
from clean_architecture.entity import Entity class UserEntity(Entity): def __init__( self, user_id, name, created_at, updated_at ): self.id = user_id self.name = name self.created_at = created_at self.updated_at = updated_at @classmethod def from_dict(cls, adict): user = UserEntity( user_id=adict.get("id"), name=adict.get("name"), created_at=adict.get("created_at"), updated_at=adict.get("updated_at") ) return user
-
Domain
- ValidRequestObject
from clean_architecture.domain import ( ValidRequestObject, InvalidRequestObject, UseCase, ResponseSuccess ) class CreateUserRequestObject(ValidRequestObject): def __init__(self, user): self.user = user if invalid_req.has_errors(): return invalid_req return CreateUserRequestObject( user=UserEntity.from_dict(adict) )
- UseCase
class CreatedUser(UseCase): def __init__(self, user_repository): self.user_repository = user_repository def process_request(self, request_object): user = self.user_repository.create(user=request_object.user) return ResponseSuccess(201, user)
-
Serializer
from schema import Schema from clean_architecture.serializer import Serializer class CreateUserEncoder(Serializer): schema = Schema( { "name": str }, ignore_extra_keys=True )
Testing
$ pytest
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size clean_architecture-0.0.2-py2-none-any.whl (11.9 kB) | File type Wheel | Python version py2 | Upload date | Hashes View |
Filename, size clean-architecture-0.0.2.tar.gz (5.6 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for clean_architecture-0.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14d2444d0dc59650e18efb8dca96ed3a169fcb24ebbd3e39d63230801916b2c7 |
|
MD5 | 2435004b951e0a919fe7a3b475440218 |
|
BLAKE2-256 | d3860381a3a2ffbe3701536222e74d9101d36bec2230659eee76c407734f0848 |