Skip to main content

Elegant service objects for Python.

Project description

unimog

Elegant service objects for Python.

Composable business logic and uniform error handling for business logic actions. A single action does one thing, and multiple actions can be organized in groups. Groups and Actions can be arbitrarily nested and form complex DAGs (directed acyclic graph).

Service objects are useful to represent complex business logic in an easy to digest form.

Usage

pip install unimog

Action

import gzip

from unimog import Action


class CompressText(Action):
    def perform(self):
        compressed_text = gzip.compress(self.context.input)
        return {"compressed_text": compressed_text}

result = CompressText()(input="Hello, World!")
result.is_success() # True
result.compressed_text # b'\x1f\x8b\x08\x00r\x92\xb7e…

Organizer

import gzip

from unimog import Action, Organizer


class CompressText(Action):
    def perform(self):
        compressed_text = gzip.compress(self.context.input)
        return {"compressed_text": compressed_text}

    
class DecompressText(Action):
    def perform(self):
        text = gzip.decompress(self.context.data)
        return {"text": text}

CompressAndDecompressText = Organizer(CompressText, DecompressText)

result = CompressAndDecompressText(input="Hello, World!")
result.is_success() # True
result.text # "Hello, World!"

Contributing

Tests

python -m pytest

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

unimog-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

unimog-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file unimog-0.1.0.tar.gz.

File metadata

  • Download URL: unimog-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.6 Darwin/23.2.0

File hashes

Hashes for unimog-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac957e1b93bb0e6a2182e80af4cf6e5497b999f316191f42a97878230f037815
MD5 e6e2482c2d2943ba81c31edc0574703d
BLAKE2b-256 cb02c7e5d59b66a249b5309793a0b402d8a96c1c30c20e402afdd230a6becb63

See more details on using hashes here.

File details

Details for the file unimog-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: unimog-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.6 Darwin/23.2.0

File hashes

Hashes for unimog-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1061f9ef28fce3bb34d691fc775678d4011aa3824956213e0c598687fcb833e6
MD5 d934e0dc89f839b0e4cab3c773fd2510
BLAKE2b-256 b4a9cda0bd3137bdf3eb5fbc87184e3ba257e447c3e3d83004f341c8d1513bba

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