Skip to content

Commit

Permalink
Read env var once
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-villavicencio-adsk committed Nov 26, 2024
1 parent b3296b9 commit 15fe99c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions shotgun_api3/shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def _is_mimetypes_broken():

SG_TIMEZONE = SgTimezone()

SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION = False

NO_SSL_VALIDATION = False
"""
Turns off hostname matching validation for SSL certificates
Expand Down Expand Up @@ -649,7 +651,11 @@ def __init__(self,
if self.config.rpc_attempt_interval < 0:
raise ValueError("Value of SHOTGUN_API_RETRY_INTERVAL must be positive, "
"got '%s'." % self.config.rpc_attempt_interval)


global SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION
if os.environ.get("SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION", "0").strip().lower() == "1":
SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION = True

self._connection = None

self.__ca_certs = self._get_certs_file(ca_certs)
Expand Down Expand Up @@ -4472,11 +4478,9 @@ def _translate_filters_simple(sg_filter):

# Payload optimization: Do not send a full object
# just send the `type` and `id` when combining related queries
enable_entity_optimization_value = os.environ.get(
"SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION", "0"
).strip()
global SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION
if (
enable_entity_optimization_value == "1"
SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION
and condition["path"] != "id"
and condition["relation"] in ["is", "is_not"]
and isinstance(values[0], dict)
Expand Down

0 comments on commit 15fe99c

Please sign in to comment.