@@ -186,6 +186,12 @@ def ensure_per_project_customization(self):
186186 'label' : 'project parameter'
187187 }, True )
188188
189+ def ensure_support_for_additional_filter_presets (self ):
190+ """Wrapper for ensure_support"""
191+ return self ._ensure_support ({
192+ 'version' : (7 , 0 , 0 ),
193+ 'label' : 'additional_filter_presets parameter'
194+ }, True )
189195
190196 def __str__ (self ):
191197 return "ServerCapabilities: host %s, version %s, is_dev %s" \
@@ -528,7 +534,8 @@ def info(self):
528534 return self ._call_rpc ("info" , None , include_auth_params = False )
529535
530536 def find_one (self , entity_type , filters , fields = None , order = None ,
531- filter_operator = None , retired_only = False , include_archived_projects = True ):
537+ filter_operator = None , retired_only = False , include_archived_projects = True ,
538+ additional_filter_presets = None ):
532539 """Calls the find() method and returns the first result, or None.
533540
534541 :param entity_type: Required, entity type (string) to find.
@@ -553,20 +560,32 @@ def find_one(self, entity_type, filters, fields=None, order=None,
553560 :param retired_only: Optional, flag to return only entities that have
554561 been retried. Defaults to False which returns only entities which
555562 have not been retired.
556-
563+
564+ :param additional_filter_presets: Optional list of presets to
565+ further filter the result set, list has the form:
566+ [{"preset_name": <preset_name>, <optional_param1>: <optional_value1>, ... }]
567+
568+ Note that these filters are ANDed together and ANDed with the 'filter'
569+ argument.
570+
571+ For details on supported presets and the format of this parameter,
572+ please consult the API documentation:
573+ https://github.com/shotgunsoftware/python-api/wiki/Reference%3A-Filter-Syntax
574+
557575 :returns: Dictionary of requested Shotgun fields and values.
558576 """
559577
560578 results = self .find (entity_type , filters , fields , order ,
561- filter_operator , 1 , retired_only , include_archived_projects = include_archived_projects )
579+ filter_operator , 1 , retired_only , include_archived_projects = include_archived_projects ,
580+ additional_filter_presets = additional_filter_presets )
562581
563582 if results :
564583 return results [0 ]
565584 return None
566585
567586 def find (self , entity_type , filters , fields = None , order = None ,
568587 filter_operator = None , limit = 0 , retired_only = False , page = 0 ,
569- include_archived_projects = True ):
588+ include_archived_projects = True , additional_filter_presets = None ):
570589 """Find entities matching the given filters.
571590
572591 :param entity_type: Required, entity type (string) to find.
@@ -593,7 +612,18 @@ def find(self, entity_type, filters, fields=None, order=None,
593612 have not been retired.
594613
595614 :param include_archived_projects: Optional, flag to include entities
596- whose projects have been archived
615+ whose projects have been archived.
616+
617+ :param additional_filter_presets: Optional list of presets to
618+ further filter the result set, list has the form:
619+ [{"preset_name": <preset_name>, <optional_param1>: <optional_value1>, ... }]
620+
621+ Note that these filters are ANDed together and ANDed with the 'filter'
622+ argument.
623+
624+ For details on supported presets and the format of this parameter,
625+ please consult the API documentation:
626+ https://github.com/shotgunsoftware/python-api/wiki/Reference%3A-Filter-Syntax
597627
598628 :returns: list of the dicts for each entity with the requested fields,
599629 and their id and type.
@@ -617,13 +647,16 @@ def find(self, entity_type, filters, fields=None, order=None,
617647 # So we only need to check the server version if it is False
618648 self .server_caps .ensure_include_archived_projects ()
619649
650+ if additional_filter_presets :
651+ self .server_caps .ensure_support_for_additional_filter_presets ()
620652
621653 params = self ._construct_read_parameters (entity_type ,
622654 fields ,
623655 filters ,
624656 retired_only ,
625657 order ,
626- include_archived_projects )
658+ include_archived_projects ,
659+ additional_filter_presets )
627660
628661 if limit and limit <= self .config .records_per_page :
629662 params ["paging" ]["entities_per_page" ] = limit
@@ -667,7 +700,8 @@ def _construct_read_parameters(self,
667700 filters ,
668701 retired_only ,
669702 order ,
670- include_archived_projects ):
703+ include_archived_projects ,
704+ additional_filter_presets ):
671705 params = {}
672706 params ["type" ] = entity_type
673707 params ["return_fields" ] = fields or ["id" ]
@@ -677,6 +711,9 @@ def _construct_read_parameters(self,
677711 params ["paging" ] = { "entities_per_page" : self .config .records_per_page ,
678712 "current_page" : 1 }
679713
714+ if additional_filter_presets :
715+ params ["additional_filter_presets" ] = additional_filter_presets ;
716+
680717 if include_archived_projects is False :
681718 # Defaults to True on the server, so only pass it if it's False
682719 params ["include_archived_projects" ] = False
@@ -695,7 +732,6 @@ def _construct_read_parameters(self,
695732 params ['sorts' ] = sort_list
696733 return params
697734
698-
699735 def _add_project_param (self , params , project_entity ):
700736
701737 if project_entity and self .server_caps .ensure_per_project_customization ():
@@ -1909,8 +1945,7 @@ def text_search(self, text, entity_types, project_ids=None, limit=None):
19091945
19101946 api_entity_types = {}
19111947 for (entity_type , filter_list ) in entity_types .iteritems ():
1912-
1913-
1948+
19141949 if isinstance (filter_list , (list , tuple )):
19151950 resolved_filters = _translate_filters (filter_list , filter_operator = None )
19161951 api_entity_types [entity_type ] = resolved_filters
0 commit comments