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
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.
Source Distribution
laibon-0.0.17.tar.gz
(16.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
laibon-0.0.17-py3-none-any.whl
(15.7 kB
view details)
File details
Details for the file laibon-0.0.17.tar.gz.
File metadata
- Download URL: laibon-0.0.17.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60050fb4ef8775e5c5f478491d02e5a5692917bd3532fa3c97cb0c499c4b1cfd
|
|
| MD5 |
21bfcc2462c0f13d4cba0dca6f5087a0
|
|
| BLAKE2b-256 |
c6d8fa71b28f936a6d89395ef9905972faebf5d85e13d10875bf56b56709f4e6
|
File details
Details for the file laibon-0.0.17-py3-none-any.whl.
File metadata
- Download URL: laibon-0.0.17-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29563a3587f851c6ecfa4f6d53d525bf9ea765b17eac3c641d62ffd8d319d9a7
|
|
| MD5 |
4b1eb1085c1b8b26d4dba18558e48afd
|
|
| BLAKE2b-256 |
1697643352edb205625997b3cbf014f9b37bc18b1b6469ad2077bd5180393fb8
|