Skip to main content

pokie-container

Tests pypi license

pokie-container is a Pokie module to manage multiple tree data structures, using the database. It features a multi-tenant, multi-tree, multi-type node closure table implementation.

Adding to a Pokie project

Just add the module name to the module list in your main.py:

(...)

def build_pokie():
    # load configuration from ENV
    cfg = Config().build()

    # modules to load & initialize
    modules = ['pokie_container', ]

    # factories to run
    factories = [PgSqlFactory]

    # build app
    pokie_app = FlaskApplication(cfg)
    flask_app = pokie_app.build(modules, factories)
    return pokie_app, flask_app


main, app = build_pokie()

(...)

Usage: basic concepts

Tree Type

A tree type works as a distinct tree identifier. A given application may have e.g. a user group tree, and an unrelated attribute tree - these would be distinct tree types within the same application. Each tree has its own node types and its own nodes; there is no underlying relationship between different tree types, their purpose is to compartmentalize different trees.

The best practice to create custom tree types is to add them to the sql migrations of a given project module, and define the appropriate constants for ID, as their numeric identifier is assigned manually by the programmer. Regardless, the pokie-container service also provides some methods to add tree types in runtime. The module also provides a default tree, conveniently using the numeric id 1.

Node Type

A node type is a node identifier that can be used for specific application logic. As an example, a LMS application may use a tree to map a virtual campus, with classrooms with different subjects. These different types of objects could be mapped as node types. The module provides a base node type, using the numeric id 1.

Node

A node is a container object that is inserted somewhere in the tree. This container object has a specific position in the tree, a node type, and an underlying tree type. It can also have a custom attribute dictionary, and external numeric reference for applicational purpose, and a string label.

Usage: populating a tree

from pokie_container.service import ContainerService
from rick.mixin import Injectable
from pokie.constants import DI_SERVICES
from pokie_container.constants import  SVC_CONTAINER, NODE_DEFAULT, TREE_DEFAULT

class SampleService(Injectable):
    
    def svc_container(self) -> ContainerService:
        return self.get_di().get(DI_SERVICES).get(SVC_CONTAINER)

    
    def create_tree_dump(self, id_tenant:int=0):
        # create a tree with the following structure
        #       A
        #      / \
        #     B   C
        #    / \
        #   D   E
        svc_container = self.svc_container()
        
        # create nodes with type NODE_DEFAULT
        # the node type is internally associated with a tree type - in this case, TREE_DEFAULT
        
        node_a = svc_container.add_node(id_tenant, NODE_DEFAULT, "node A")
        node_b = svc_container.add_node(id_tenant, NODE_DEFAULT, "node B", id_parents=node_a.id)
        node_c = svc_container.add_node(id_tenant, NODE_DEFAULT, "node C", id_parents=node_a.id)
        node_d = svc_container.add_node(id_tenant, NODE_DEFAULT, "node D", id_parents=node_b.id)
        node_e = svc_container.add_node(id_tenant, NODE_DEFAULT, "node E", id_parents=node_b.id)

        tree = svc_container.get_node_tree(id_tenant, TREE_DEFAULT)
        # dump tree
        print(tree)

Metadata

Release files for pokie-container 0.9.2

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

Source distribution (sdist)

Source distribution for pokie-container 0.9.2
File Size Uploaded Provenance
pokie_container-0.9.2.tar.gz 14.4 kB With provenance Details

Release files / pokie_container-0.9.2.tar.gz

Download URL pokie_container-0.9.2.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e7de917813315a23d2679a02ac72657d8b2a6b0f921690f2be84a64671aa2ef4
BLAKE2b-256 checksum
How to use checksums
647dbdd3f0724b2fd29c410d0c02788c29bd5c92d003720d4cf007b2055cc653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 5, 2025.

Transparency log

Security for pokie-container 0.9.2

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.

Full provenance

All 1 file in this release has been uploaded with provenance metadata.

Attestation for pokie_container-0.9.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 5, 2025.

Transparency log

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