def relationship_list_save(relationship_dicts, package, attr, context):
    allow_partial_update = context.get('allow_partial_update', False)
    if ((relationship_dicts is None) and allow_partial_update):
        return
    model = context['model']
    session = context['session']
    relationship_list = getattr(package, attr)
    old_list = relationship_list[:]
    relationships = []
    for relationship_dict in (relationship_dicts or []):
        obj = d.table_dict_save(relationship_dict, model.PackageRelationship, context)
        relationships.append(obj)
    relationship_list[:] = relationships
    for relationship in (set(old_list) - set(relationship_list)):
        relationship.state = 'deleted'
        relationship_list.append(relationship)
def relationship_list_save(relationship_dicts, package, attr, context):
    allow_partial_update = context.get('allow_partial_update', False)
    if ((relationship_dicts is None) and allow_partial_update):
        return
    model = context['model']
    session = context['session']
    relationship_list = getattr(package, attr)
    old_list = relationship_list[:]
    relationships = []
    for relationship_dict in (relationship_dicts or []):
        obj = d.table_dict_save(relationship_dict, model.PackageRelationship, context)
        relationships.append(obj)
    relationship_list[:] = relationships
    for relationship in (set(old_list) - set(relationship_list)):
        relationship.state = 'deleted'
        relationship_list.append(relationship)