Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal here is a hook that can actually create new requests. This gives the execution policy the ability to control the execution of a request in pyramid to the extent that it can throw away all state and try again similar to what could be done in middleware.
I'm writing this for the purpose of pyramid_tm which wants to support "retryable" requests in which the request failed for transient reason where there is a reasonable idea that the request will succeed if tried again. When performing a retry we want to teardown state as much as possible to avoid any state leaking from the failing request into the new request (such as managed objects for aborted transactions).
The key difference between this API and a tween is that the execution policy can create a new request with an assurance that nothing else is wrapping it, depending on the old request object and its old state. Whether this is worth the introduction of the API or not is up for debate but I think it is after trying to implement pyramid_tm without it.