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