Skip to content
Snippets Groups Projects
Verified Commit c16728f5 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček
Browse files

modules/{policy,view}: do not act if FAIL or DONE

Not all actions are destructive, but it seems generally expected that if
an earlier module or other code already transitioned the request into
a FAIL or DONE state, we don't want to apply rules anymore.
In particular, later rule actions would "overwrite" what previous
actions did.
parent 1f2986db
1 merge request!678view: change to a more natural semantics
......@@ -549,12 +549,18 @@ end
-- as a dependency chain, e.g. r1,r2,r3 -> r3(r2(r1(state)))
policy.layer = {
begin = function(state, req)
-- Don't act on "resolved" cases.
if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end
req = kres.request_t(req)
return policy.evaluate(policy.rules, req, req:current(), state) or
policy.evaluate(policy.special_names, req, req:current(), state) or
state
end,
finish = function(state, req)
-- Don't act on "resolved" cases.
if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end
req = kres.request_t(req)
return policy.evaluate(policy.postrules, req, req:current(), state) or state
end
......
......@@ -106,7 +106,9 @@ end
-- @function Module layers
view.layer = {
begin = function(state, req)
if state == kres.FAIL then return state end
-- Don't act on "resolved" cases.
if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end
req = kres.request_t(req)
evaluate(state, req)
return req.state
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment