#NEWLINE# def hydrate_runcaseversions( self , bundle ) : #NEWLINE# #INDENT# '\n        Handle the runcaseversion creation during a POST of a new Run.\n\n        Tastypie handles the creation of the run itself.  But we handle the\n        RunCaseVersions and Results because we have special handler methods for\n        setting the statuses which we want to keep DRY.\n\n        ' #NEWLINE# try : #NEWLINE# #INDENT# run = bundle . obj #NEWLINE# run . save ( ) #NEWLINE# for data in bundle . data [ 'runcaseversions' ] : #NEWLINE# #INDENT# status = data . pop ( 'status' ) #NEWLINE# cv = CaseVersion . objects . get ( productversion = run . productversion , case = data . pop ( 'case' ) ) #NEWLINE# ( rcv , created ) = RunCaseVersion . objects . get_or_create ( run = run , caseversion = cv ) #NEWLINE# data [ 'user' ] = bundle . request . user #NEWLINE# data [ 'environment' ] = Environment . objects . get ( pk = data [ 'environment' ] ) #NEWLINE# rcv . get_result_method ( status ) ( ** cv ) #NEWLINE# #UNINDENT# bundle . data [ 'runcaseversions' ] = [ ] #NEWLINE# return bundle #NEWLINE# #UNINDENT# except KeyError as e : #NEWLINE# #INDENT# raise ValidationError ( 'bad result object data missing key: {0}' . format ( e ) ) #NEWLINE# #UNINDENT# except ObjectDoesNotExist as e : #NEWLINE# #INDENT# raise ValidationError ( e )