Skip to main content

docversion

PyPI version PyPI status Python versions Downloads License: AGPL v3 Ruff mypy

Python knihovna pro správu verzí dokumentů postavená na Pydantic 2, Beanie 2 a MongoDB. Navržena pro použití ve FastAPI projektech.

Požadavky

  • Python ≥ 3.11
  • MongoDB ≥ 6
  • pymongo ≥ 4.9 (přímé async rozhraní bez Motor)

Instalace

pip install sysnet-docversion

Nebo s uv:

uv add sysnet-docversion

Rychlý start

1. Definujte model dokumentu

from docversion import VersionedDocument

class Clanek(VersionedDocument):
    nazev: str
    obsah: str

    class Settings:
        name = "clanky"

2. Inicializujte databázi

from docversion import init_db

await init_db("mongodb://localhost:27017", "moje_db", [Clanek])

3. Práce s verzemi

# Vytvoření dokumentu
clanek = Clanek(nazev="Úvod", obsah="Hello, world!")
await clanek.insert()

# Uložení s verzí
clanek.obsah = "Upravený obsah"
await clanek.save_version(author="alice", message="první úprava")

# Výpis verzí
verze = await clanek.list_versions()
for v in verze:
    print(f"v{v.version} — {v.author}: {v.message}")

# Načtení konkrétní verze
snapshot = await clanek.get_version(1)
print(snapshot.data)

# Návrat k předchozí verzi
await clanek.revert_to_version(1, author="bob", message="vrátit k v1")

4. Soft-delete

# Smazání (soft)
await clanek.soft_delete(deleted_by="alice")

# Obnovení
await clanek.restore(restored_by="bob")

Konfigurace

Přepínání verzování

Verzování lze vypnout na úrovni třídy nebo prostřednictvím proměnné prostředí:

class Clanek(VersionedDocument):
    class Settings:
        name = "clanky"
        versioning = False  # vypnuto pro celou třídu
DOCVERSION_ENABLED=0  # vypnuto globálně

Pro jednorázové volání bez verze:

await clanek.save_version(versioning=False)

Přepínání soft-delete

class Clanek(VersionedDocument):
    class Settings:
        name = "clanky"
        soft_delete = False  # vždy fyzické smazání
DOCVERSION_SOFT_DELETE_ENABLED=0

API

VersionedDocument

Metoda Popis
save_version(author, message, *, versioning) Uloží dokument a volitelně zaznamená snapshot verze
list_versions() Vrátí seznam metadat verzí seřazených vzestupně
get_version(version) Načte plný snapshot dané verze
revert_to_version(to_version, author, message) Obnoví pole dokumentu do stavu dané verze; vytvoří nový snapshot
soft_delete(deleted_by, *, soft_delete) Označí dokument jako smazaný (nebo fyzicky odstraní)
restore(restored_by) Obnoví soft-smazaný dokument

DocumentVersion

Neměnný snapshot uložený v kolekci document_versions. Obsahuje pole data (dict), version (int), author, message a created_at.

init_db(mongodb_uri, database, document_models)

Inicializuje Beanie ODM. Musí být zavoláno před jakýmikoli DB operacemi.

Závislosti

Licence

Tento projekt je licencován pod GNU Affero General Public License v3.0.

Metadata

Release files for sysnet-docversion 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sysnet-docversion 0.1.3
File Size Uploaded Provenance Actions
sysnet_docversion-0.1.3.tar.gz 85.3 kB Without provenance Details for sysnet_docversion-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sysnet-docversion 0.1.3
File Interpreter ABI Platform Actions
sysnet_docversion-0.1.3-py3-none-any.whl Python 3 none any Details for sysnet_docversion-0.1.3-py3-none-any.whl

Total release size: 99.0 kB

Release files / sysnet_docversion-0.1.3.tar.gz

Download URL sysnet_docversion-0.1.3.tar.gz
Size 85.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d0291944eff7c2bdac8ac274888132f89e42dd03334c548602d3fe3d8d53d8fb
BLAKE2b-256 checksum
How to use checksums
50911c545e36d79ec5800338b75ba11c8a308a7f9d94afbe54fa093dba942a22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}

Release files / sysnet_docversion-0.1.3-py3-none-any.whl

Download URL sysnet_docversion-0.1.3-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad5cfa38fb4f2d9a62bbfaee0accff8fd9a7a92290e457f67f4c5d1a2a50bb2b
BLAKE2b-256 checksum
How to use checksums
dadd38e88a6ac7df6075a835823a1717efa68ec6191f60945ccac591c1eba243
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}

Security for sysnet-docversion 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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