check_permission()
Checks whether the current user has the requested permissions on an object via
DMS.CheckPermission (single flag) or DMS.CheckPermissions (multiple flags).
To check whether an object may be inserted at a specific location, pass 0
as model, set write=True, and specify the target via folder_id or
register_id.
1. Signature
-
Sync
-
Async
ecm.dms.check_permission(
model: _ECMModelBase | int,
object_type_id: int | None = None,
*,
read: bool = False,
write: bool = False,
execute: bool = False,
delete: bool = False,
update: bool = False,
folder_id: int | ECMFolderModel | None = None,
register_id: int | ECMRegisterModel | None = None,
register_type: int | None = None,
) -> bool
await ecm.dms.check_permission(
model: _ECMModelBase | int,
object_type_id: int | None = None,
*,
read: bool = False,
write: bool = False,
execute: bool = False,
delete: bool = False,
update: bool = False,
folder_id: int | ECMFolderModel | None = None,
register_id: int | ECMRegisterModel | None = None,
register_type: int | None = None,
) -> bool
2. Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
|
|
— |
Either an ECM model instance (its |
|
|
|
The numeric object type ID. If |
|
|
|
Check for read index data permission ( |
|
|
|
Check for write index data permission ( |
|
|
|
Check for open/execute permission ( |
|
|
|
Check for delete permission ( |
|
|
|
Check for update object permission ( |
|
|
|
ID of the folder or an |
|
|
|
ID of the parent register or an |
|
|
|
Type of the parent register. |
At least one of read, write, execute, delete, or update must be True.
|
3. Access flags
| Flag | Parameter | Description |
|---|---|---|
|
|
Read index data of the object. |
|
|
Write index data of the object. |
|
|
Open or execute the object. |
|
|
Delete the object. |
|
|
Update the object (replace files). |
When a single flag is requested, the server call DMS.CheckPermission is used.
When multiple flags are requested, DMS.CheckPermissions is used instead.
5. Exceptions
| Exception | Condition |
|---|---|
|
|
|
|
6. Examples
6.1. Check read permission on a document
-
Sync
-
Async
doc = ecm.dms.get(InvoiceDocument, 12345)
if ecm.dms.check_permission(doc, read=True):
print("Read access granted")
doc = await ecm.dms.get(InvoiceDocument, 12345)
if await ecm.dms.check_permission(doc, read=True):
print("Read access granted")
6.2. Check multiple permissions at once
-
Sync
-
Async
if ecm.dms.check_permission(12345, read=True, write=True, delete=True):
print("Full access")
else:
print("Restricted access")
if await ecm.dms.check_permission(12345, read=True, write=True, delete=True):
print("Full access")
else:
print("Restricted access")
6.3. Check insert permission at a folder location
-
Sync
-
Async
folder = ecm.dms.select(InvoiceFolder).execute()[0]
if ecm.dms.check_permission(0, object_type_id=327685, write=True, folder_id=folder):
print("Insert allowed in this folder")
folder = (await ecm.dms.select(InvoiceFolder).execute())[0]
if await ecm.dms.check_permission(0, object_type_id=327685, write=True, folder_id=folder):
print("Insert allowed in this folder")