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

Netsuite dynamic host addressing #2

Merged
merged 7 commits into from
Mar 6, 2020

Conversation

merit-sno
Copy link

@merit-sno merit-sno commented Mar 4, 2020

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.

netsuite/client.py Outdated Show resolved Hide resolved
netsuite/client.py Outdated Show resolved Hide resolved
netsuite/client.py Outdated Show resolved Hide resolved
netsuite/client.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@merit-mthompson
Copy link

@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?

Comment on lines 100 to 110
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)
Copy link

@merit-mthompson merit-mthompson Mar 5, 2020

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,
    )

Choose a reason for hiding this comment

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

Copy link
Author

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.

Copy link

@merit-mthompson merit-mthompson left a 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.

Copy link
Member

@merit-schelcj merit-schelcj left a 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.

@merit-sno merit-sno merged commit 5da22d0 into master Mar 6, 2020
@merit-mthompson merit-mthompson deleted the netsuite-dynamic-host-addressing branch March 6, 2020 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants