Skip to content
12 changes: 11 additions & 1 deletion shotgun_api3/shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ def __init__(self, sg):
self.session_token = None
self.authorization = None
self.no_ssl_validation = False
self.localized = True

@property
def records_per_page(self):
Expand Down Expand Up @@ -469,7 +470,8 @@ def __init__(self,
password=None,
sudo_as_login=None,
session_token=None,
auth_token=None):
auth_token=None,
localized=True):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I might default this to False. My fear would be that this will change the form of the data returned by the API and might break existing client scripts (or even stuff in Toolkit that we provide) without additional code changes to compensate for it.

"""
Initializes a new instance of the Shotgun client.

Expand Down Expand Up @@ -538,6 +540,9 @@ def __init__(self,
``auth_token`` is invalid.
.. todo: Add this info to the Authentication section of the docs

:param bool localized: A boolean to asks for some fields to be localized. When ``True``, a
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This does not match the parameters of the constructor.

header ``locale`` with value ``auto`` is added to HTTP requests. Default is ``True``.

.. note:: A note about proxy connections: If you are using Python <= v2.6.2, HTTPS
connections through a proxy server will not work due to a bug in the :mod:`urllib2`
library (see http://bugs.python.org/issue1424152). This will affect upload and
Expand Down Expand Up @@ -598,6 +603,7 @@ def __init__(self,
self.config.convert_datetimes_to_utc = convert_datetimes_to_utc
self.config.no_ssl_validation = NO_SSL_VALIDATION
self.config.raw_http_proxy = http_proxy
self.config.localized = localized

try:
self.config.rpc_attempt_interval = int(os.environ.get("SHOTGUN_API_RETRY_INTERVAL", 3000))
Expand Down Expand Up @@ -3205,6 +3211,10 @@ def _call_rpc(self, method, params, include_auth_params=True, first=False):
"content-type": "application/json; charset=utf-8",
"connection": "keep-alive"
}

if self.config.localized is True:
req_headers["locale"] = "auto"

http_status, resp_headers, body = self._make_call("POST", self.config.api_path,
encoded_payload, req_headers)
LOG.debug("Completed rpc call to %s" % (method))
Expand Down