Python plumbing for micro-framework based applications
Project description
rick
Python plumbing library for building microframework-based applications
Rick provides essential building blocks and utilities for constructing robust Python applications using your preferred microframework.
Features
Core Components
- Dependency Injection - Flexible DI container with singleton/factory patterns
- Service Registry - Dynamic class registration and factory loading
- Container Classes - Type-safe configuration and data containers
Validation & Forms
- Comprehensive Validators - 30+ built-in validators including new
intandidlistvalidators - Form Processing - Request validation with nested records and custom error messages
- Input Filters - Transform and sanitize input data
Security
- Cryptography - Secure password hashing with BCrypt and Fernet256 encryption
- Redis Cache Security - Built-in encryption support for sensitive cached data
- Security Policy - Comprehensive security guidelines and best practices
Resource Management
- Configuration Loading - Environment variables and JSON file configuration
- Redis Integration - Full-featured cache facade with optional encryption
- Stream Processing - Multipart stream reader with seek support
- Console Utilities - Colored console output helpers
Installation
pip install rick
Quick Start
Basic Dependency Injection
from rick.base import Di
# Register dependencies
di = Di()
di.add(MyService)
di.add('config', {'api_key': 'secret'})
# Retrieve instances
service = di.get(MyService)
config = di.get('config')
Form Validation
from rick.form import RequestRecord, Field
class UserForm(RequestRecord):
fields = {
'username': Field(validators='required|string|min:3|max:20'),
'email': Field(validators='required|email'),
'age': Field(validators='required|int|min:18'),
'friend_ids': Field(validators='idlist') # New validator
}
form = UserForm()
if form.is_valid(request_data):
user_data = form.get_data()
else:
errors = form.get_errors()
Secure Redis Cache
from rick.resource.redis import CryptRedisCache
# Encrypted cache for sensitive data
cache = CryptRedisCache(
key='your-64-char-encryption-key',
host='localhost',
port=6379
)
cache.set('user:123', sensitive_data, ttl=3600)
data = cache.get('user:123')
Development
Requirements
- Python 3.8+
- Redis (for cache features)
- Docker (for running tests with testcontainers)
Setting Up Development Environment
# Clone the repository
git clone https://git.oddbit.org/OddBit/rick.git
cd rick
# Install with development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=rick
# Run linting
flake8 rick/ tests/
Running Tests with Tox
# Run all tests
tox
# Run specific Python version
tox -e py310
# Run linting only
tox -e flake
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
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
rick-0.7.1.tar.gz
(46.7 kB
view details)
File details
Details for the file rick-0.7.1.tar.gz.
File metadata
- Download URL: rick-0.7.1.tar.gz
- Upload date:
- Size: 46.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3b833cedaf6c1705401429f763e02279321f6517216e54ea8cd5e7a329c87d0
|
|
| MD5 |
d1a1a548f94d4a102639123873ac72b0
|
|
| BLAKE2b-256 |
9966142ec8368d030c3399506b4ca7f7a5dd709464209f51830baa9c69f3cfd4
|