Some unfinished, broken additions to processes
This commit is contained in:
		| @@ -189,15 +189,25 @@ end | ||||
| -- rename_org(old_name, new_name) | ||||
| -- Renames an org  | ||||
|  | ||||
| -- =================================================================== | ||||
| -- POLICIES | ||||
| -- Each policy is a table with a string for a key. Contents: | ||||
| -- KEY - name of the policy (string) | ||||
| -- [member orgs]: external orgs allowed to call policy | ||||
| -- [function]: the function that initiates the policy | ||||
| -- =================================================================== | ||||
|  | ||||
| -- =================================================================== | ||||
| -- modpol.add_policy | ||||
| -- Adds a policy to an org's [org].policies table | ||||
| -- Params: org_name (string), target_function (string), | ||||
| -- policy_function (string) | ||||
| -- function names should be in the form [module?.][function] | ||||
| -- and can be modpol.delegate(org_name) | ||||
| -- Params: org_name (string), | ||||
| -- policy_name (string), | ||||
| -- policy_table (table) | ||||
| -- Output: true if successful, nil if error | ||||
| modpol.add_policy = function(org_name, target_function, policy_function) | ||||
|  | ||||
| -- TKTK NEEDS TO BE REWRITTEN | ||||
|  | ||||
| modpol.add_policy = function(org_name, policy_name, policy_table) | ||||
|    -- first, basic checks | ||||
|    local message = "Error: No such org" | ||||
|    if (modpol.orgs[org_name] == nil) then | ||||
|   | ||||
| @@ -3,28 +3,50 @@ | ||||
| -- Process-related functions for Modular Politics | ||||
| -- Called by modpol.lua | ||||
|  | ||||
| -- TKTK may need to create high-level modpol.processes table to hold ongoing processes | ||||
| -- TKTK in order to enable async processes. Rewrite all this as listeners | ||||
| -- =================================================================== | ||||
| -- modpol.processes, a high-level table of active processes | ||||
| -- Process table structure: | ||||
| -- [name]: unique name | ||||
| -- [org]: org | ||||
| -- [update_functions]: table of available update functions | ||||
| -- [state]: table of relevant data on the state of the function | ||||
|  | ||||
| modpol.processes = {} | ||||
|  | ||||
| -- =================================================================== | ||||
| -- Function: modpol.switchboard | ||||
| -- Params: org (string), routine (string) | ||||
| -- Outputs: Checks the org for any policies related to a given function; | ||||
| -- Function: modpol.register_process | ||||
| -- Adds a process to modpol.processes | ||||
|  | ||||
| -- =================================================================== | ||||
| -- Function: modpol.delegate_process | ||||
| -- Delegates a process from one org to another | ||||
|  | ||||
| -- =================================================================== | ||||
| -- Function: modpol.begin_process | ||||
| -- Params: user (string), org (string), action (string) | ||||
| -- Outputs: Checks the org for any policies related to a given action; | ||||
| -- Calls the modpol.initiate.* function(org) based on policy | ||||
| -- Defaults to modpol.initiate.consent() | ||||
| modpol.switchboard = function(org, routine) | ||||
|     if modpol.orgs[org]["policies"]  | ||||
|         and modpol.orgs[org]["policies"][routine] then | ||||
|         -- TKTK if there exists a policy, initiate that function | ||||
|     else | ||||
|         modpol.initiate.consent(org) | ||||
|     end | ||||
| modpol.begin_process = function(user, org, action) | ||||
|    if modpol.orgs[org]["policies"]  | ||||
|       and modpol.orgs[org]["policies"][routine] then | ||||
|       -- check user org membership is satisfied | ||||
|       -- register process | ||||
|       -- start the appropriate process | ||||
|    else | ||||
|             -- register process (or does .initiate.* do that?) | ||||
|             modpol.initiate.consent(org) | ||||
|    end | ||||
| end | ||||
|  | ||||
| -- =================================================================== | ||||
| -- TKTK | ||||
| -- Function: modpol.delegate | ||||
| -- Delegates a process from one org to another | ||||
| -- Function: modpol.update_process | ||||
|  | ||||
| -- =================================================================== | ||||
| -- Function: modpol.end_process | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| -- =================================================================== | ||||
| @@ -68,8 +90,6 @@ modpol.approved = function() | ||||
|     return true | ||||
| end | ||||
|  | ||||
|  | ||||
|  | ||||
| -- =================================================================== | ||||
| -- Experimental | ||||
| -- =================================================================== | ||||
|   | ||||
		Reference in New Issue
	
	Block a user