A py permission management module.
Project description
Permitronix
Permitronix is a Python permission management module that allows you to manage permission tables for users and objects.
Installation
Permitronix can be installed via pip:
pip install permitronix
Usage
Permitronix
The Permitronix
class allows you to manage permission tables for objects. Here is an example of how to
use Permitronix
:
from permitronix import Permitronix
from permitronix.permission_node import PermissionNode
from permitronix.permission_table import PermissionTable
# Create a permitronix instance
ptx = Permitronix({})
# Set a permission for an object
obj = "example"
with ptx.enter(obj) as v:
pt: PermissionTable = v.value
pt.set_permission(PermissionNode('regular_expressions_for_some_permissions_.*', 'scope_id:1145'))
# Get the permission table for an object
pt = ptx.get_permission_table(obj)
# Remove a permission table for an object
ptx.rem_permission_obj(obj)
# Check if a permission table exists for an object
exists = ptx.exists(obj)
Permission Table
The PermissionTable
class allows you to define permission tables for users and objects. Here is an example of how to
create a permission table:
from permitronix import Permitronix
from permitronix.permission_node import PermissionNode
from permitronix.permission_table import PermissionTable
# Create a permitronix instance
ptx = Permitronix({})
# Create a permission table
pt = PermissionTable(ptx, 'data')
pt.set_permission(PermissionNode('regular_expressions_for_some_permissions_.*', 'scope_id:1145'))
Permission Node
A PermissionNode
is a node in the permission tree. Each node has a name and a permission level. Here is an example of
how to create a permission node:
from permitronix.permission_level import PermissionLevel
from permitronix.permission_node import PermissionNode
# Create a permission node
pn = PermissionNode("admin", PermissionLevel("op:12"))
Contributing
We welcome contributions from anyone who is interested in improving this project. If you find any issues, bugs, or have suggestions for improvement, please feel free to open an issue or submit a pull request.
We will review your changes and provide feedback if necessary. Thank you for your contributions!
License
This source code is licensed under the MIT license
and may be used for any purpose consistent with local law, provided
that the copyright notice is retained.
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
Built Distribution
File details
Details for the file Permitronix-1.1.3.tar.gz
.
File metadata
- Download URL: Permitronix-1.1.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8f057b29d1a8cec4d2676606beaa2d9be0cb60443c06c120b14964b75b8bd0d |
|
MD5 | d3aa97e83c5f1db38792982ea9482cf1 |
|
BLAKE2b-256 | b4eee76bf6a62719eb611bc3bc939e90b9f867d0625addc2a6bfce5faa75c786 |
File details
Details for the file Permitronix-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: Permitronix-1.1.3-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12bcd0504d63c03caede55f7253c77075c809315298f9cc80f7d04b703de2597 |
|
MD5 | e5e7af1a2de896a92abfd25b88f95091 |
|
BLAKE2b-256 | 7c19162292c5fe72d888db1b27a56f08ea7a2439a0fbd8b23763fe8f3ea8e5da |