Powered by Tachyonic Project Luxon Framework v0.0.0

Luxon Framework for rapid application development. (luxon)

Version

Policy Engine

Luxon comes with a policy engine. Policy rule sets can be written in Json and will be compiled to Python.

Compiler Class

luxon.core.policy.compiler.compiler()[source]

Policy Rules Compiler.

Compiles rule set into python executable machine code for enhanced performance during conditional matching.

Example of rule_set in dict format:
{ ‘role:admin’: ‘“admin” in role_kwarg’,
‘user:login’: ‘“login_kwarg” is True’, ‘match:both’: ‘$role:admin or $system:login’ }

The syntax for the rule is exactly as per python conditional statements. Note these statements can be nested using braces ().

Parameters:dict_rule_set (dict) – Rule Set loaded from JSON file for example.

Policy Class

class luxon.core.policy.policy.Policy(rule_set=None, **kwargs)[source]

Policy Rule Engine interface.

Used to validate rules against environmental arguements provided as kwargs.

rule_set can be provided which will be compiled for better performance.

Example of rule_set in dict format:
{ ‘role:admin’: ‘“admin” in role_kwarg’,
‘user:login’: ‘“login_kwarg” is True’, ‘match:both’: ‘role:admin or system:login’ }

The syntax for the rule is exactly as per python conditional statements. Note these statements can be nested using braces ().

By default following kwargs are given to policy runtime in wsgi:
  • req being equel to the Request Object for the request.
Keyword Arguments:
 rule_set (dict) – Rule Set in dict loaded from JSON file for example.
validate(rule)[source]

Validate Access to view.

Parameters:view (str) – View Name

A helper function can be used to create Policy objects

Policy Helper

luxon.helpers.policy.policy(**kwargs)[source]

Policy helper function

Spawns a Policy() object with the rule set specified in the policy.json file.