digest()

Returns the digest of a document object via std.GetDocumentDigest.

By default (calculate=False) the digest stored in the database is returned. When calculate=True, the server calculates a fresh digest from the actual document files and returns both the stored and the calculated digest, allowing integrity verification.

1. Signature

  • Sync

  • Async

ecm.dms.digest(
    model: ECMDocumentModel | int,
    object_type_id: int | None = None,
    *,
    calculate: bool = False,
) -> ECMDocumentDigest
await ecm.dms.digest(
    model: ECMDocumentModel | int,
    object_type_id: int | None = None,
    *,
    calculate: bool = False,
) -> ECMDocumentDigest

2. Parameters

Parameter Type Default Description

model

ECMDocumentModel | int

Either an ECMDocumentModel instance (its id is used) or a plain integer document object ID.

object_type_id

int | None

None

The numeric object type ID. If None, the type is extracted from the model instance when available, or resolved via get_object_type_by_id() for plain integer IDs.

calculate

bool

False

When True, the server calculates the digest from the actual document files and also returns local_digest. When False, only the stored database digest is returned.

3. Return value

An ECMDocumentDigest instance.

3.1. ECMDocumentDigest fields

Field Type Description

table_digest

str

The digest value stored in the database. Always present.

local_digest

str | None

The freshly calculated digest from the actual files. Only set when calculate=True, None otherwise.

4. Exceptions

Exception Condition

ValueError

model is an ECMDocumentModel instance with id set to None.

ECMNotFoundException

object_type_id is None and no object with the given ID exists on the server.

5. Examples

5.1. Read the stored digest

  • Sync

  • Async

doc = ecm.dms.select(InvoiceDocument).where(InvoiceDocument.Title == "Invoice").execute()[0]
result = ecm.dms.digest(doc)
print(result.table_digest)
doc = (await ecm.dms.select(InvoiceDocument).where(InvoiceDocument.Title == "Invoice").execute())[0]
result = await ecm.dms.digest(doc)
print(result.table_digest)

5.2. Verify integrity by comparing stored vs. calculated digest

  • Sync

  • Async

result = ecm.dms.digest(doc, calculate=True)
if result.table_digest == result.local_digest:
    print("Integrity OK")
else:
    print(f"Mismatch! stored={result.table_digest} calculated={result.local_digest}")
result = await ecm.dms.digest(doc, calculate=True)
if result.table_digest == result.local_digest:
    print("Integrity OK")
else:
    print(f"Mismatch! stored={result.table_digest} calculated={result.local_digest}")

5.3. Use with a plain object ID

  • Sync

  • Async

# Provide object_type_id to avoid an extra server round trip
result = ecm.dms.digest(12345, object_type_id=327685)
print(result.table_digest)
result = await ecm.dms.digest(12345, object_type_id=327685)
print(result.table_digest)

6. See also