Updated response policy to use registered op and redo the request where indicated
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from core.apirequest import executeRequest
|
from core.apirequest import executeRequest
|
||||||
|
from core.execution import processregistry
|
||||||
|
|
||||||
def responsePolicy(response, action, outputs, resolved):
|
def responsePolicy(response, action, outputs, resolved):
|
||||||
if hasattr(action, "responsepolicy"):
|
if hasattr(action, "responsepolicy"):
|
||||||
|
#if processregistry.registeredOp:
|
||||||
|
#currentOp = processregistry.registeredOp
|
||||||
|
#print(registeredOp[action.name]["response"])
|
||||||
|
#print(currentOp)
|
||||||
|
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
logging.warning(f"{response} during {action.name}")
|
logging.warning(f"{response} during {action.name}")
|
||||||
|
|
||||||
@@ -11,11 +17,19 @@ def responsePolicy(response, action, outputs, resolved):
|
|||||||
if policy["statuscode"] == response.status_code:
|
if policy["statuscode"] == response.status_code:
|
||||||
logging.warning(policy["print"])
|
logging.warning(policy["print"])
|
||||||
|
|
||||||
newresponse = executeRequest(policy["execute"], outputs, resolved)
|
from core.execution.executioncontract import executeContract
|
||||||
|
executeContract(policy["execute"])
|
||||||
|
|
||||||
|
#newresponse = executeRequest(action, outputs, resolved)
|
||||||
|
|
||||||
if policy["response_update"]:
|
if policy["response_update"]:
|
||||||
logging.info("Updating response")
|
logging.info("Updating response")
|
||||||
print("Updating response")
|
newresponse = executeRequest(action, outputs, resolved)
|
||||||
|
|
||||||
|
#response = newresponse
|
||||||
|
if processregistry.registeredOp:
|
||||||
|
response = processregistry.registeredOp[action.name]["response"]
|
||||||
|
else:
|
||||||
response = newresponse
|
response = newresponse
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user