From 9d409d12afce0738d1dd89446a46e5faf926a644 Mon Sep 17 00:00:00 2001 From: Kenneth Li Date: Wed, 12 Oct 2022 12:26:55 -0400 Subject: [PATCH 1/4] added log --- shopify/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shopify/base.py b/shopify/base.py index 47f40cb3..6f7c2dea 100644 --- a/shopify/base.py +++ b/shopify/base.py @@ -72,6 +72,7 @@ def set_password(cls, value): password = property(get_password, set_password, None, "The password for HTTP Basic Auth.") def get_site(cls): + print('site -> {}'.format(getattr(cls._threadlocal, "site", ShopifyResource._site))) return getattr(cls._threadlocal, "site", ShopifyResource._site) def set_site(cls, value): @@ -147,6 +148,8 @@ def set_version(cls, value): version = property(get_version, set_version, None, "Shopify Api Version") def get_url(cls): + output = getattr(cls._threadlocal, "url", ShopifyResource._url) + print(output) return getattr(cls._threadlocal, "url", ShopifyResource._url) def set_url(cls, value): From 8261c3d4cea1e805938f6db6a3caf6ef2b89d532 Mon Sep 17 00:00:00 2001 From: Kenneth Li Date: Wed, 12 Oct 2022 12:35:44 -0400 Subject: [PATCH 2/4] more logs --- shopify/resources/graphql.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shopify/resources/graphql.py b/shopify/resources/graphql.py index 33525ef1..2609b3b9 100644 --- a/shopify/resources/graphql.py +++ b/shopify/resources/graphql.py @@ -21,6 +21,10 @@ def execute(self, query, variables=None, operation_name=None): headers = self.merge_headers(default_headers, self.headers) data = {"query": query, "variables": variables, "operationName": operation_name} + print('request endpoint -> {}'.format(self.endpoint)) + print('request data -> {}'.format(json.dumps(data).encode("utf-8"))) + print('request headers -> {}'.format(headers)) + req = urllib.request.Request(self.endpoint, json.dumps(data).encode("utf-8"), headers) try: From 1d7e291abbb15a680cbd458993e213b19cfa1e19 Mon Sep 17 00:00:00 2001 From: Kenneth Li Date: Wed, 12 Oct 2022 13:13:26 -0400 Subject: [PATCH 3/4] modify url and headers --- shopify/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shopify/base.py b/shopify/base.py index 6f7c2dea..07da216f 100644 --- a/shopify/base.py +++ b/shopify/base.py @@ -7,6 +7,7 @@ import sys from six.moves import urllib import six +import os from shopify.collection import PaginatedCollection from pyactiveresource.collection import Collection @@ -72,7 +73,8 @@ def set_password(cls, value): password = property(get_password, set_password, None, "The password for HTTP Basic Auth.") def get_site(cls): - print('site -> {}'.format(getattr(cls._threadlocal, "site", ShopifyResource._site))) + if os.environ.get('SHOPIFY_HOST_IPADDR'): + return os.environ.get('SHOPIFY_HOST_IPADDR') return getattr(cls._threadlocal, "site", ShopifyResource._site) def set_site(cls, value): @@ -104,7 +106,10 @@ def set_timeout(cls, value): def get_headers(cls): if not hasattr(cls._threadlocal, "headers"): cls._threadlocal.headers = ShopifyResource._headers.copy() - return cls._threadlocal.headers + headers = cls._threadlocal.headers + if os.environ.get('SHOPIFY_HOST_IPADDR'): + headers['SHOPIFY-DOMAIN'] = getattr(cls._threadlocal, "site", ShopifyResource._site) + return headers def set_headers(cls, value): cls._threadlocal.headers = value From a2cbb31f74600a508c9d1a02e818df7bc95cb611 Mon Sep 17 00:00:00 2001 From: Kenneth Li Date: Wed, 12 Oct 2022 13:31:06 -0400 Subject: [PATCH 4/4] change environ check --- shopify/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shopify/base.py b/shopify/base.py index 07da216f..97fa0935 100644 --- a/shopify/base.py +++ b/shopify/base.py @@ -73,8 +73,8 @@ def set_password(cls, value): password = property(get_password, set_password, None, "The password for HTTP Basic Auth.") def get_site(cls): - if os.environ.get('SHOPIFY_HOST_IPADDR'): - return os.environ.get('SHOPIFY_HOST_IPADDR') + if os.environ.get('SHOPIFY_HOST'): + return os.environ.get('SHOPIFY_HOST') return getattr(cls._threadlocal, "site", ShopifyResource._site) def set_site(cls, value): @@ -107,7 +107,7 @@ def get_headers(cls): if not hasattr(cls._threadlocal, "headers"): cls._threadlocal.headers = ShopifyResource._headers.copy() headers = cls._threadlocal.headers - if os.environ.get('SHOPIFY_HOST_IPADDR'): + if os.environ.get('SHOPIFY_HOST'): headers['SHOPIFY-DOMAIN'] = getattr(cls._threadlocal, "site", ShopifyResource._site) return headers