Skip to main content

Eluvia Base

Schema

eluvia.integrations.schemas.Empty

Empty object is a singleton which purpose is to define unset value.

eluvia.integrations.schemas.empty

Empty is instance of the Empty object. The value bool(empty) is False which can simplify value checking implementations.

eluvia.integrations.schemas.Dataclass

Dataclass is base class for service integration data objects. The class static method map_from_dict is a factory class that initialize object from a dict. It provides simple way how to convert a service response in a JSON format to the data class object. Example:

from uuid import UUID
from dataclasses import dataclass

from eluvia.integrations.schemas import Dataclass, Empty, empty

@dataclass
class Role(Dataclass):
    
    name: str | Empty = empty

@dataclass
class User(Dataclass):
    
    id: UUID
    name: str | Empty = empty
    email: str | Empty = empty
    role: Role | Empty = empty


response_data = {
    'id': 'd2aa2bd0-b040-4348-9a18-4b717582048c',
    'name': 'Pert',
    'email': 'petr@eluvia.com',
    'role': {
        'name': 'capitan'
    }
}

User.map_from_dict(response_data)  # will create User and related Role objects

eluvia.integrations.signals

Signals is a module that provides two signals schema_obj_post_save and schema_obj_post_delete that are emitted if schema object is saved or deleted. You can use reciever decorator to register a callback function to the signal.

from eluvia.integrations.signals import schema_obj_post_save, receiver


@receiver(schema_obj_post_save, sender=MySchema)
def my_callback(sender, instance, **kwargs):
    print(f'{sender} object {instance} was saved')

More signals can be registered to the same callback function.

from eluvia.integrations.signals import schema_obj_post_save, schema_obj_post_delete, receiver


@receiver([schema_obj_post_save, schema_obj_post_delete], sender=MySchema)
def my_callback(sender, **kwargs):
    print(f'{sender} object was saved')

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eluvia_base-2.0.2.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

eluvia_base-2.0.2-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file eluvia_base-2.0.2.tar.gz.

File metadata

  • Download URL: eluvia_base-2.0.2.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.21

File hashes

Hashes for eluvia_base-2.0.2.tar.gz
Algorithm Hash digest
SHA256 30c4926f1ca49561be32c539c7992e74211f32b6e17bbe46d9a86832cd83caef
MD5 8faa03b606e7d8f39fb83f4be4a49c03
BLAKE2b-256 441ca0c1c53cf9fe6b4047c888d01c2ab433155664d8724bae117021f5d521d4

See more details on using hashes here.

File details

Details for the file eluvia_base-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: eluvia_base-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.21

File hashes

Hashes for eluvia_base-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c57d715d0086c020c4ca45b05b604c6c8c520052c85d71d9d97c73e29b24cbed
MD5 5a08ce7dc35389fe454c1604a5ebed6d
BLAKE2b-256 4cdf1de71e99fac282322d06a72f83413d58c12c7c05b415ea9a45e56c5cc780

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page