class activelogic.Resource

This is the parent class for all resources.

Connection instantiates all resources:

c = await conn.config()
rs = await conn.ruleset()

Each resource defines a subset of the system’s configuration and has its own set of privileges in the user database:

  • None - User can’t access the resource at all.

  • Read - User can run read-only commands on the resource.

  • Write - User can run all commands on the resource.

A session attached to the resource will always be in a transaction. There is also implicit locks on each resource that are taken when the first manipulative command is sent, and released when changes are committed or rolled back.

Changes to database-bound resources, such like Config and Ruleset must be committed to take effect. This either can be done using a context manager or by just calling commit():

# Alt 1.
async with await conn.config() as c:
    await c.update('DRDL_ENABLED', True)

# Alt 2.
await c.update('DRDL_ENABLED', True)
await c.commit()

Issuing commands on an outdated resource will result in that PLDBNewDataCommitted is raised.

class activelogic.Flag

Object representing a flag definition.


name (str) – Name of the flag definition.

class activelogic.Service

Object representing a service definition.


name (str) – Name of the service definition.

class activelogic.AppName

Object representing a appname definition.

  • name (str) – Name of the AppName/AppCategory

  • type_id (int) – id of the referred AppName/AppCategory

class activelogic.AppContent

Object representing a appcontent definition.

  • name (str) – Name of the AppContent

  • type_id (int) – id of the referred AppContent

class activelogic.AppCategory

Object representing a appcategory definition.


name (str) – Name of the appcategory definition.


The machine id of the system that owns the resource.

>>> res.machineid

The firmware version running on the system that owns the resource.

>>> res.distversion
async Resource.list(cls)

Generic list function for definitions that does not belong to any specific resource.


cls – Object type that determines what kind of data to get.


A list of given dataclass type.

  • ValueError – Invalid dataclass type.

  • PLDBNewDataCommitted – Conflict with new data committed by an other session.

Resources may override this method, but will fallback to this generic method if cls does not match any resource-specific type. Definitions listen in this method cannot be modified:

  • AppCategory

  • AppContent

  • AppName

  • Service

  • Flag

List may or may not be cached, depending on if cache_enabled is set.



Sets the commit message of the next commit.


commit_message (str) –

This function is typically used for setting proper commit message in context manager-based commits:

>>> with conn.config() as c:
...     c.update("GEOLOGIC_ENABLED", True)
...     c.set_commit_message("Enable GeoLogic function")
async Resource.commit(commit_message=None)

Stores the current transaction to the database.


commit_message (str) – Message recorded in the commit log.

This command makes your changes visible to others.

It is usually a good practice to commit changes in batches. In particular if changes are committed to Ruleset. This will reload the ruleset and take a lot of CPU resources from the system.

async Resource.rollback()

Aborts the current transaction and discards the changes.

This also automatically happens if your connection drops or you exit the program without committing your changes.

async Resource.wait_for_commit()

Sits down and waits until another session commits changes to the resource.

>>> res.wait_for_commit()

The amount of time spent on waiting for the commit to happen, can be limited using the built-in timeout support:

    await asyncio.wait_for(rs.wait_for_commit(), timeout=5)
except asyncio.TimeoutError:

Resource Cache


Enables or disables the caching mechanism for the resource.


enable (bool) – True or False.

For optimal performance, caching should always be enabled. All resources have their caching enabled by default.


Invalidates a specific cache, or all caches tied to the current resource.

The cache is always invalidated if the current transaction is rolled back or committed.


cache_id (str) – Id of the cache to invalidate, or empty if all caches should be invalidated.



Sends a message to session to test if it is up.


data (bytes) – Data to send.


The echo reply from remote session.