Xapian-based user profile management with schema validation and automatic index routing
Project description
XProfile
A Python package for Xapian-based user profile management with schema validation and automatic index routing.
Overview
xprofile provides the XProfile model class, built on top of xapian_model.base.BaseXapianModel. It offers a comprehensive schema for storing and managing user profiles in Xapian indexes with automatic routing based on entity ID and profile admin API ID.
Features
- Xapian-Based Storage: Leverages Xapian for efficient full-text search and retrieval
- Automatic Index Routing: Routes documents to appropriate indexes using configurable templates
- Comprehensive Schema: Includes fields for personal, business, reseller, and other profile types
- Zero Dependencies: Pure Python implementation with no external runtime dependencies
- Type-Safe: Full type hints support for Python 3.12+
- Well-Documented: Google-style docstrings throughout the codebase
Installation
pip install xapian-profile
Development Installation
Requirements: Python 3.12 or higher (specified in .python-version)
Clone the repository and install in editable mode:
git clone git@github.com:Dubalu-Development-Team/xprofile.git
cd xprofile
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e .
Using direnv (recommended): If you have direnv installed, the virtual environment with the correct Python version will be automatically created and activated when you enter the project directory. Just run:
direnv allow
Usage
Security Configuration
For security reasons, INDEX_TEMPLATE and schema _foreign field must be defined in your application code:
from xprofile import XProfile
from xprofile.utils import get_encoded_uuid, get_slug
# Define your own profile identifiers (keep these secret!)
PROFILES_ADMIN_API = "Your Profile Admin API Name"
PROFILE_ADMIN_API_ID = get_encoded_uuid(get_slug(PROFILES_ADMIN_API))
PROFILE_SCHEMA = "Your Profile Schema Name"
PROFILE_SCHEMA_ID = get_encoded_uuid(get_slug(PROFILE_SCHEMA))
# Create a subclass with your configuration
class MyProfile(XProfile):
INDEX_TEMPLATE = '{entity_id}/{profile_admin_api_id}'
# Configure the schema _foreign field
MyProfile.SCHEMA['_schema']['_foreign'] = f'.schemas/{PROFILE_SCHEMA_ID}'
MyProfile.SCHEMA['_schema']['_meta']['description'] = PROFILE_SCHEMA
# Now use your profile
profile = MyProfile(
entity_id="your-entity-id",
profile_admin_api_id=PROFILE_ADMIN_API_ID
)
Basic Usage
# Access the schema
schema = MyProfile.SCHEMA
# The schema includes fields for:
# - Basic info: name, slug, is_active
# - Profile types: personal, business, reseller, etc.
# - Contact info: email, phone with validation
# - Timestamps: created_at, updated_at, deleted_at
# - And more...
Profile Types
XProfile supports multiple profile types:
personal- Personal user profilesbusiness- Business organization profilesreseller- Reseller accountsreferral- Referral program participantssupplier- Supplier accountsmashup- Mashup service profilesaffinity- Affinity group profilesdssupplier- Data supplier profiles
Schema
The profile schema includes comprehensive field definitions with:
- Type validation (string, uuid, boolean, date, json, etc.)
- Index configuration (terms, field_terms, field_all, none)
- Required/optional field markers
- Null value handling
- Default values
- Field-specific constraints
Access the complete schema via XProfile.SCHEMA or import get_profile_schema() from xprofile.schemas.
Project Structure
xprofile/
├── src/
│ └── xprofile/
│ ├── __init__.py # Package exports
│ ├── models.py # XProfile model class
│ ├── schemas.py # Schema definitions and constants
│ └── utils.py # Utility functions (slug, UUID generation)
├── pyproject.toml # Project configuration
├── CLAUDE.md # Development guidelines
└── README.md # This file
Development
Requirements
- Python 3.12 or higher
xapian_modelpackage (for BaseXapianModel)
Code Style
- Line length: 120 characters
- Type hints required for all public functions and methods
- Google-style docstrings for all classes, methods, and functions
- PEP 695 type hints and modern Python syntax
Building
The project uses Hatchling as the build backend:
pip install build
python -m build
License
Copyright (c) 2019-2024 Dubalu International LLC. All Rights Reserved.
See LICENSE for license details.
Authors
Dubalu Framework Team. See AUTHORS for full list of contributors.
Links
- GitHub: Dubalu-Development-Team/xprofile
- Dubalu Framework: https://dubalu.com
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
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
File details
Details for the file xapian_profile-0.1.0.tar.gz.
File metadata
- Download URL: xapian_profile-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3565069e0dcdcdfffb6296f94f134957e9ba4253992eb19808392cfc892e02bf
|
|
| MD5 |
f7d1fb1a6a14d77ba2f4d18dbbff4d79
|
|
| BLAKE2b-256 |
afb23074d6e9014c9789d3ba992e2baff05eb4649c5fd323cc701e9f60ea8c4f
|
File details
Details for the file xapian_profile-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xapian_profile-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c36c1d50f84f609a3241f92ea5170b0c36e0a3936f1690be76707aa9c751057a
|
|
| MD5 |
d2111ec28753b08ee9c84a184f28261f
|
|
| BLAKE2b-256 |
9a7b466c7976c6f54f216eb171d743e73af2e06f44311dedb505677e4252ea3b
|