-
Notifications
You must be signed in to change notification settings - Fork 44
Fix/post requests #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ddyett
reviewed
Apr 23, 2020
ddyett
reviewed
Apr 23, 2020
ddyett
reviewed
Apr 23, 2020
ddyett
reviewed
Apr 23, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This PRs makes the following changes
Why make these changes
GraphSession extends Session with Graph use cases like adding support for middleware options. To do this we were building a Request object and passing it through the middleware pipeline, together with other arguments -- **kwargs. This is where I went wrong with the previous implementation.
The _prepare_and_send_request method, built the request object, removed the scopes from **kwargs and mutated the request object by adding to it a scopes property. This was done because the Request constructor doesn't expect scopes to be passed. It then sends the request object down the pipeline with some arguments. This breaks the send method -- bug -- when it gets arguments it doesn't expect like headers.
To fix this, I needed to stop drilling arguments from users to the send method. That means, I need to stop calling
send
in_prepare_and_send_request
. So I decided to call Session's HTTP methods in GraphSession instead of prepare_and_send request.instead of
But now we have another bug, if we call
graph_session.get('/me', scopes=[])
,get
will break becausesuper().get(url, **kwargs)
doesn't expectscopes
to be in**kwargs
. So I had to figure out a way of removingscopes
or more broadlymiddleware options
-- from **kwargs -- before we callsuper().get(url, **kwargs)
. I did this using a decorator.The decorater lives in the MiddlewareControl class.
This how it is used
For all requests, the decorator does the following;
middleware_options
property, so that they are not persisted across requestssuper().get(url, **kwargs)
middleware_options
, for use in the middleware pipeline.The
MiddlewareController
is exposed as a singleton for use in theMiddlewarePipeline
. The snippet below demonstrates how it is used.Fixes #39
Closes #13
Fixes AB#4607