6161+v3.0.5 - 2010 Dec 20
6262 + officially remove support for old api3_preview controller
6363 + find(): allow requesting a specific page of results instead of returning them all at once
64-
65- +v3.0.4 - 2010 Nov 22
66- + fix for issue where create() method was returning list type instead of dictionary
67- + support new style classes (thanks to Alex Schworer https://github.com/schworer)
64+ + add support for "session_uuid" parameter for communicating with a web browser session.
6865
6966+v3.0.3 - 2010 Nov 12
7067 + add support for local files. Injects convenience info into returned hash for local file links
@@ -261,6 +258,18 @@ def _get_thumb_url(self, entity_type, entity_id):
261258 # if it's an error, message is printed on second line
262259 raise ValueError , "%s:%s " % (entity_type ,entity_id )+ f .read ().strip ()
263260
261+ def set_session_uuid (self , session_uuid ):
262+ server_options = {
263+ 'server_url' : self .api_url ,
264+ 'script_name' : self .script_name ,
265+ 'script_key' : self .api_key ,
266+ 'http_proxy' : self .http_proxy ,
267+ 'convert_datetimes_to_utc' : self .convert_datetimes_to_utc ,
268+ 'session_uuid' : session_uuid
269+ }
270+
271+ self ._api3 = ShotgunCRUD (server_options )
272+
264273 def schema_read (self ):
265274 resp = self ._api3 .schema_read ()
266275 return resp ["results" ]
@@ -314,48 +323,48 @@ def schema_entity_read(self):
314323 def find (self , entity_type , filters , fields = None , order = None , filter_operator = None , limit = 0 , retired_only = False , page = 0 ):
315324 """
316325 Find entities of entity_type matching the given filters.
317-
326+
318327 The columns returned for each entity match the 'fields'
319328 parameter provided, or just the id if nothing is specified.
320-
329+
321330 Limit constrains the total results to its value.
322-
331+
323332 Returns an array of dict entities sorted by the optional
324333 'order' parameter.
325334 """
326335 if fields == None :
327336 fields = ['id' ]
328337 if order == None :
329338 order = []
330-
339+
331340 if type (filters ) == type ([]):
332341 new_filters = {}
333342 if not filter_operator or filter_operator == "all" :
334343 new_filters ["logical_operator" ] = "and"
335344 else :
336345 new_filters ["logical_operator" ] = "or"
337-
346+
338347 new_filters ["conditions" ] = []
339348 for f in filters :
340349 new_filters ["conditions" ].append ( {"path" :f [0 ],"relation" :f [1 ],"values" :f [2 :]} )
341-
350+
342351 filters = new_filters
343352 elif filter_operator :
344353 raise ShotgunError ("Deprecated: Use of filter_operator for find() is not valid any more. See the documention on find()" )
345-
354+
346355 if retired_only :
347356 return_only = 'retired'
348357 else :
349358 return_only = 'active'
350-
359+
351360 req = {
352361 "type" : entity_type ,
353362 "return_fields" : fields ,
354363 "filters" : filters ,
355364 "return_only" : return_only ,
356365 "paging" : {"entities_per_page" : self .records_per_page , "current_page" : 1 }
357366 }
358-
367+
359368 if order :
360369 req ['sorts' ] = []
361370 for sort in order :
@@ -365,14 +374,14 @@ def find(self, entity_type, filters, fields=None, order=None, filter_operator=No
365374 if not sort .has_key ('direction' ):
366375 sort ['direction' ] = 'asc'
367376 req ['sorts' ].append ({'field_name' : sort ['field_name' ],'direction' : sort ['direction' ]})
368-
377+
369378 if type (limit ) != int or limit < 0 :
370379 raise ValueError ("find() 'limit' parameter must be a positive integer" )
371380 elif (limit and limit > 0 and limit < self .records_per_page ):
372381 req ["paging" ]["entities_per_page" ] = limit
373-
382+
374383 records = []
375-
384+
376385 # if page is specified, then only return the page of records requested
377386 if type (page ) != int or page < 0 :
378387 raise ValueError ("find() 'page' parameter must be a positive integer" )
@@ -397,9 +406,9 @@ def find(self, entity_type, filters, fields=None, order=None, filter_operator=No
397406 req ['paging' ]['current_page' ] += 1
398407 else :
399408 done = True
400-
409+
401410 records = self ._inject_field_values (records )
402-
411+
403412 return records
404413
405414 def find_one (self , entity_type , filters , fields = None , order = None , filter_operator = None , retired_only = False ):
@@ -650,6 +659,10 @@ class ShotgunCRUD(object):
650659 def __init__ (self , options ):
651660 self .__sg_url = options ['server_url' ]
652661 self .__auth_args = {'script_name' : options ['script_name' ], 'script_key' : options ['script_key' ]}
662+
663+ if 'session_uuid' in options :
664+ self .__auth_args ['session_uuid' ] = options ['session_uuid' ]
665+
653666 if 'convert_datetimes_to_utc' in options :
654667 convert_datetimes_to_utc = options ['convert_datetimes_to_utc' ]
655668 else :
0 commit comments