diff --git a/shotgun_api3/shotgun.py b/shotgun_api3/shotgun.py index 6c5aab59..d84422d1 100644 --- a/shotgun_api3/shotgun.py +++ b/shotgun_api3/shotgun.py @@ -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 @@ -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) @@ -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)