Skip to main content

Common utilities and shared code for PRS microservices

Project description

PRS Commons

PyPI Version Python Versions License: MIT Downloads

A Python library containing common utilities and shared code for PRS microservices, including a high-level Odoo RPC client.

📖 Documentation | 🐛 Issue Tracker | 📦 PyPI

Features

  • AWS S3 Integration: Async S3 client for file operations
  • PostgreSQL Client: Async PostgreSQL client with connection pooling
  • Odoo RPC Client: High-level client for interacting with Odoo's XML-RPC API
  • Type Annotations: Full type hints for better IDE support
  • Environment Variable Support: Easy configuration via .env files
  • Async/Await Support: Built with modern Python async/await syntax

Installation

From PyPI (Recommended)

pip install prs-commons

From Source (Development Only)

For development or contributing to the project:

For development, clone and install in editable mode:

git clone https://<token>@github.com/IshaFoundationIT/prs-facade-common.git
cd prs-facade-common
pip install -e ".[dev]"  # Install with development dependencies

From Private Package Repository

Add your private package repository to pip configuration and install:

# Configure pip to use your private repository
pip config set global.extra-index-url https://your.private.registry.com/simple/

# Install the package
pip install prs-commons

Quick Start

Odoo RPC Client

from prs_commons.odoo.rpc_client import OdooRPClient
from dotenv import load_dotenv

# Initialize the client (singleton)
client = OdooRPClient()

# Search for records
try:
    # Search for active partners
    domain = [('is_company', '=', True), ('active', '=', True)]
    fields = ['id', 'name', 'email']
    partners = client.search_read('res.partner', domain, fields=fields)

    # Create a new record
    new_partner_id = client.create_record('res.partner', {
        'name': 'John Doe',
        'email': 'john@example.com',
        'is_company': False
    })

    # Update a record
    client.write_record('res.partner', [new_partner_id], {
        'email': 'john.doe@example.com'
    })

except Exception as e:
    print(f"Error: {e}")

Configuration

Create a .env file in your project root:

ODOO_HOST=your-odoo-host.com
ODOO_DB=your_database
ODOO_LOGIN=your_email@example.com
ODOO_PASSWORD=your_password

Documentation

For full documentation, please see the API Reference.

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Development

Prerequisites

  • Python 3.11+
  • Poetry (recommended) or pip

Setup

  1. Clone the repository:

    git clone https://<token>@github.com/IshaFoundationIT/prs-facade-common.git
    cd prs-facade-common
    
  2. Install dependencies:

    # Using Poetry
    poetry install --with dev
    
    # Or using pip
    pip install -e ".[dev]"
    
  3. Install pre-commit hooks:

    pre-commit install
    

Running Tests

# Run all tests
pytest

# Run with coverage report
pytest --cov=prs_commons --cov-report=term-missing

Publishing New Versions

Prerequisites

  1. Set up your ~/.pypirc file with your GitHub token:

    [distutils]
    index-servers =
        github
    
    [github]
    repository = https://upload.pypi.org/legacy/
    username = __token__
    password = your_github_token_here
    

    Replace your_github_token_here with a GitHub Personal Access Token with write:packages scope.

  2. Update the version in pyproject.toml

  3. Build the package:

    python -m build
    
  4. Publish to GitHub Package Registry:

    python -m twine upload --repository github dist/*
    

Contributing

  1. Create a feature branch
  2. Make your changes
  3. Run tests and pre-commit checks
  4. Submit a pull request

License

MIT

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

prs_commons-0.2.8.tar.gz (8.2 MB view details)

Uploaded Source

Built Distribution

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

prs_commons-0.2.8-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file prs_commons-0.2.8.tar.gz.

File metadata

  • Download URL: prs_commons-0.2.8.tar.gz
  • Upload date:
  • Size: 8.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for prs_commons-0.2.8.tar.gz
Algorithm Hash digest
SHA256 c3f04239ebde4eb6869530b0deaee36e57f49a5790d8c5e6cacd174b146dfc6d
MD5 a4b0fa3fc6df877480cd904528c7c341
BLAKE2b-256 fc48dcd5ad192e7d066b3f68654f69c26b1ddafa9da89037e39655625644e69c

See more details on using hashes here.

File details

Details for the file prs_commons-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: prs_commons-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for prs_commons-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 56999bf2ece8302065af9d23fcab0f81580880cf0450c3036f04a8bf13a8b30a
MD5 f64aa014c4911ba6e1d23f8155c44798
BLAKE2b-256 f6c055b0e11bd694434bcc24b730bd3a6f556c2a5b91bf0459eace016a4357af

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