Skip to content
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

Add custom session injection, Fix bug for http_options #1119

Merged
merged 5 commits into from
Sep 28, 2022
Merged

Conversation

jacalata
Copy link
Contributor

No description provided.

jacalata and others added 2 commits September 22, 2022 15:50
* ssl-verify is an option, not a header
* Allow injection of session_factory to allow use of a custom session
Copy link
Collaborator

@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I love the session factory approach to be honest. It feels like a pretty advanced use case. We also aren't sure that the http_options interface we have is going to work with or apply to every possible session type .

If we really do want support that case. I think it's slightly safer/more-robust if we:

  • Make session_factory a kw-only argument, and make the default None.
  • Then in the __init__ method if factory is None use requests.session

I think that makes it less likely to accidentally set it, and protect against an oopsie in changing the signature in the future

Regardless, for the http_options bit, left a few comments

tableauserverclient/server/server.py Outdated Show resolved Hide resolved
tableauserverclient/server/server.py Outdated Show resolved Hide resolved
@@ -60,12 +54,13 @@ class PublishMode:
Overwrite = "Overwrite"
CreateNew = "CreateNew"

def __init__(self, server_address, use_server_version=False, http_options=None):
def __init__(self, server_address, use_server_version=False, http_options=None, session_factory=requests.Session):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, server_address, use_server_version=False, http_options=None, session_factory=requests.Session):
def __init__(self, server_address, use_server_version=False, http_options=None, *, session_factory=None):
if session_factory is None:
self._session = requests.Session()
else:
self._session = session_factory()

jacalata and others added 3 commits September 23, 2022 15:36
Pylint with "errors only" isn't 100% accurate, but it found a few problems
that should be fixed.
@jacalata jacalata merged commit ef9e7fd into master Sep 28, 2022
@jacalata jacalata deleted the development branch September 28, 2022 07:41
@jacalata jacalata restored the development branch September 28, 2022 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants