def package_relationship_update(context, data_dict):
 model = context['model']
 schema = (context.get('schema') or schema_.default_update_relationship_schema())
 (id, id2, rel) = _get_or_bust(data_dict, ['subject', 'object', 'type'])
 pkg1 = model.Package.get(id)
 pkg2 = model.Package.get(id2)
 if (not pkg1):
  raise NotFound(('Subject package %r was not found.' % id))
 if (not pkg2):
  return NotFound(('Object package %r was not found.' % id2))
 (data, errors) = _validate(data_dict, schema, context)
 if errors:
  model.Session.rollback()
  raise ValidationError(errors)
 _check_access('package_relationship_update', context, data_dict)
 existing_rels = pkg1.get_relationships_with(pkg2, rel)
 if (not existing_rels):
  raise NotFound('This relationship between the packages was not found.')
 entity = existing_rels[0]
 comment = data_dict.get('comment', u'')
 context['relationship'] = entity
 return _update_package_relationship(entity, comment, context)

def package_relationship_update ( context , data_dict ) : model = context [ 'model' ] schema = ( context . get ( 'schema' ) or schema_ . default_update_relationship_schema ( ) ) ( id , id2 , rel ) = _get_or_bust ( data_dict , [ 'subject' , 'object' , 'type' ] ) pkg1 = model . Package . get ( id ) pkg2 = model . Package . get ( id2 ) if ( not pkg1 ) : raise NotFound ( ( 'Subject package %r was not found.' % id ) ) if ( not pkg2 ) : return NotFound ( ( 'Object package %r was not found.' % id2 ) ) ( data , errors ) = _validate ( data_dict , schema , context ) if errors : model . Session . rollback ( ) raise ValidationError ( errors ) _check_access ( 'package_relationship_update' , context , data_dict ) existing_rels = pkg1 . get_relationships_with ( pkg2 , rel ) if ( not existing_rels ) : raise NotFound ( 'This relationship between the packages was not found.' ) entity = existing_rels [ 0 ] comment = data_dict . get ( 'comment' , u'' ) context [ 'relationship' ] = entity return _update_package_relationship ( entity , comment , context )
update a relationship between two datasets .