-
Notifications
You must be signed in to change notification settings - Fork 1
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
Netsuite dynamic host addressing #2
Conversation
@merit-sno this looks awesome, nice work on the quick PR. For testing/linting I've just cloned things locally and done some light poking mostly just for syntax. Do we have more formal test steps to validate the functionality of these changes? |
netsuite/client.py
Outdated
def __init__(self, **kwargs): | ||
""" | ||
Assign the dynamic host domain component to a class variable | ||
""" | ||
wsdl_url = kwargs['wsdl_url'] | ||
kwargs.pop('wsdl_url',None) | ||
|
||
parsed_wsdl_url = urlparse(wsdl_url) | ||
self._wsdl_url = f'{parsed_wsdl_url.scheme}://{parsed_wsdl_url.netloc}/' | ||
|
||
super().__init__(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this maybe turn in to:
def __init__(self, wsdl_url, *args, **kwargs):
"""
Assign the dynamic host domain component to a class variable
"""
parsed_wsdl_url = urlparse(wsdl_url)
self._wsdl_url = f'{parsed_wsdl_url.scheme}://{parsed_wsdl_url.netloc}/'
super().__init__(*args, **kwargs)
It makes the init() requirement of wsdl_url more explicit and saves you the trouble of having to manipulate args/kwargs for the super(). (Generally, kwargs are optional arguments while positional args are required. It's also not very common in Python to pop kwargs like that.)
Then when you instantiate the class you remove the key and pass the URL as a positional argument.
return NetSuiteTransport(
self._generate_wsdl_url(),
session=self.session,
cache=self.cache,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And for a deeper-dive into args/kwargs: https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-python-3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like bad form to mix arguments by position, generic list, and key/value all in the same call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to see the init follow Python-isms a bit more closely. Otherwise, looks great. I'm not trying to be a weenie about how we do things, just trying to follow best practices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than changing the author details. Leave the original authors info intact. If these changes aren't accepted upstream then we update this info.
Problem
NetSuite WSDL now relies on dynamic host addresses for accessing subscriber based WSDL documents. With NetSuite 2020.1, this becomes a requirement, and zeep appears to have a failure to recognize NetSuite's use of relative addressing.
Solution
Wrap zeep.transports.transport with a dynamic address manager that updates the get and post services to use subscriber assigned dynamic addressing.