Skip to main content

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
  • Async API: Built on top of xapian_model>=0.3.1 with full async/await support via httpx
  • 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...

# Create, save, and query are async operations (xapian_model 0.3.0+)
profile = await MyProfile.objects.create(
    entity_id="your-entity-id",
    profile_admin_api_id=PROFILE_ADMIN_API_ID,
    name="Example",
)
await profile.save()
results = await MyProfile.objects.filter(query="Example", entity_id="your-entity-id")

Profile Types

XProfile supports multiple profile types:

  • personal - Personal user profiles
  • business - Business organization profiles
  • reseller - Reseller accounts
  • referral - Referral program participants
  • supplier - Supplier accounts
  • mashup - Mashup service profiles
  • affinity - Affinity group profiles
  • dssupplier - 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_model>=0.3.1 package (for BaseXapianModel, async API via pyxapiand>=2.1.0)

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-2026 Dubalu International LLC. All Rights Reserved.

See LICENSE for license details.

Authors

Dubalu Framework Team. See AUTHORS for full list of contributors.

Links

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

xapian_profile-0.2.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

xapian_profile-0.2.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file xapian_profile-0.2.1.tar.gz.

File metadata

  • Download URL: xapian_profile-0.2.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for xapian_profile-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f6e8a8f519be6a76d6c67b0ab77e1277fe4cd3541791cd2ddcd26e82e1ab249c
MD5 f2079e5b219efdb1b8f3c0d4e88542e8
BLAKE2b-256 bfa9d7b4e9b12309b84c9e6fd9f25264326cc44d0e4ae4b2cc3a4dda1cd385a0

See more details on using hashes here.

File details

Details for the file xapian_profile-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: xapian_profile-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for xapian_profile-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 86492ff96142886ab64c5abcd61d35c44140a880b195feb3b695cd7ec28faf5b
MD5 1af5235509d62f774cdf35c889fe25b5
BLAKE2b-256 3f73d68bdf8cb1ef3893436912cd3487fc7fdb992bafb227ee853612ef0df4be

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