Skip to main content

Shared base logic used across AldanDev projects.

Project description

PyPI - Python Version PyPI version

notora

Shared base logic used across AldanDev projects.

  • v1 (legacy): notora.v1
  • v2 (next-gen toolkit): notora.v2

v2 quickstart

from notora.v2.repositories import Repository, RepoConfig
from notora.v2.services import RepositoryService, ServiceConfig

repo = Repository(
    User,
    config=RepoConfig(default_limit=50),
)
service = RepositoryService(
    repo,
    config=ServiceConfig(detail_schema=UserSchema, list_schema=UserListSchema),
)

v2 docs

  • docs/v2/index.md
  • docs/v2/models.md
  • docs/v2/repositories.md
  • docs/v2/services.md
  • docs/v2/query-dsl.md
  • docs/v2/pagination.md
  • docs/v2/m2m.md
  • docs/v2/recipes.md

Listing and pagination

from notora.v2.repositories import QueryParams, PaginationParams

rows = await service.list_raw(
    session,
    limit=None,  # no limit
)

params = QueryParams(filters=[...], ordering=[...], limit=None)
rows = await service.list_raw_params(session, params)

page = await service.paginate_params(
    session,
    PaginationParams(limit=20, offset=0, filters=[...]),
)

Repository/service factories

from notora.v2.repositories import build_repository, RepoConfig
from notora.v2.services import build_service, ServiceConfig

repo = build_repository(User, config=RepoConfig(default_limit=25))
service = build_service(User, repo=repo, service_config=ServiceConfig(detail_schema=UserSchema))

Query DSL (FastAPI-friendly)

from fastapi import Depends
from notora.v2.repositories import (
    FilterField,
    QueryParams,
    QueryInput,
    SortField,
    build_query_params,
    make_query_params_dependency,
)

filter_fields = {
    'name': FilterField(resolver=lambda m: m.name, value_type=str),
    'age': FilterField(resolver=lambda m: m.age, value_type=int, operators={'eq', 'gte', 'lte'}),
}
sort_fields = {
    'name': SortField(resolver=lambda m: m.name),
    'created_at': SortField(resolver=lambda m: m.created_at),
}

def query_params(query: QueryInput = Depends()) -> QueryParams[User]:
    return build_query_params(
        query,
        model=User,
        filter_fields=filter_fields,
        sort_fields=sort_fields,
    )

query_params_dep = make_query_params_dependency(
    model=User,
    filter_fields=filter_fields,
    sort_fields=sort_fields,
)

# Example request:
# /users?filter=name:eq:john&filter=age:gte:18&sort=-created_at&limit=20&offset=0

Supported operators: eq, ne, lt, lte, gt, gte, in, ilike, isnull.

M2M sync modes

from notora.v2.services import M2MSyncMode

class UserService(RepositoryService[UUID, User, UserSchema]):
    m2m_sync_mode: M2MSyncMode = M2MSyncMode.ADD

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

notora-0.17.0.tar.gz (124.3 kB view details)

Uploaded Source

Built Distribution

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

notora-0.17.0-py3-none-any.whl (55.0 kB view details)

Uploaded Python 3

File details

Details for the file notora-0.17.0.tar.gz.

File metadata

  • Download URL: notora-0.17.0.tar.gz
  • Upload date:
  • Size: 124.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for notora-0.17.0.tar.gz
Algorithm Hash digest
SHA256 99b602db11d7ec4ad0d1d4f8cab310913fc2b695caa71e74d36f1380f215cfc0
MD5 3b333a559228bda28b7925b9bf10d0d1
BLAKE2b-256 5f63423e037ac4e47080af4c7afdeaae5f75c2d7e5dd4987b1d309d5061532e5

See more details on using hashes here.

File details

Details for the file notora-0.17.0-py3-none-any.whl.

File metadata

  • Download URL: notora-0.17.0-py3-none-any.whl
  • Upload date:
  • Size: 55.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for notora-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cbc309c00ee59ab7b5ac025ff0cd1d3306d33bcf3ab4881fa565c5d3a564972
MD5 2812b073fbe690be1e779d1bcd64cc5e
BLAKE2b-256 8cf3e733ce2cc2431ffdfddefe04d5b9b99cb298f8c3b1e949774c56146f9ba6

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