Skip to main content

Common library for django development

Project description

Laibon

Laibon is a collection of useful common classes that can go a long way to help in developing a django based web application.

Features

  • Database Access: Abstract adapter pattern for clean separation between business logic and Django models
  • Flow Management: Activity-based workflow execution with conditional jumps and error handling
  • Container Pattern: Thread-safe key-value storage for passing data between activities
  • JSON Validation: Schema-based request validation with caching for performance
  • Exception Handling: Comprehensive exception hierarchy for different error scenarios

Installation

From PyPI:

python3 -m pip install laibon

From TestPyPI:

pip install --extra-index-url https://testpypi.python.org/pypi laibon

Quick Examples

Database Adapter Pattern

from laibon.db import Adapter, BaseModel

class UserAdapter(Adapter):
    def __init__(self, entity_id=None, name=None, email=None):
        super().__init__(entity_id)
        self.name = name
        self.email = email
    
    def to_model(self, existing=None):
        if existing:
            existing.name = self.name
            return existing
        return UserModel(name=self.name, email=self.email)

Flow Management

from laibon.rtf import FlowDefinition, FlowRunner

flow = FlowDefinition("User Registration")
flow.add(ValidateInputActivity) \
    .jump_if(ValidationResult.INVALID, ErrorActivity) \
    .jump_default(CreateUserActivity)

runner = FlowRunner(data_container)
runner.run_flow(flow)

JSON Validation

from laibon.rest import JSONSchemaValidator

try:
    JSONSchemaValidator.validate_schema(
        {"name": "John", "age": 30}, 
        "user/create_request.json"
    )
except JSONValidationException:
    # Handle validation error
    pass

Requirements

  • Python >= 3.8
  • Django >= 4.2
  • jsonschema >= 4.0.0

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

laibon-0.0.12.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

laibon-0.0.12-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file laibon-0.0.12.tar.gz.

File metadata

  • Download URL: laibon-0.0.12.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for laibon-0.0.12.tar.gz
Algorithm Hash digest
SHA256 d1aa7091b157b2f323ccf6c489bff51e8669fa6b242e014d10d9a2df182ac4f9
MD5 1d8ec1464cfa46d1351620a77f3847ad
BLAKE2b-256 ad6abceb6a972a985f7f01a76287df66c667e029560716a025ff6336cdcfdfda

See more details on using hashes here.

File details

Details for the file laibon-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: laibon-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for laibon-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 d05a66a4307dd1046d2ad0e2ce26d550d63ce231c49244878636cb314ff18abb
MD5 42c344f671d0f7ce56df85f2e28f1c77
BLAKE2b-256 7f7e581ec081f3e80a9b284742823102eb879e145d712eae6304c78391e67f5d

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