def package_resource_list_save(res_dicts, package, context):
    allow_partial_update = context.get('allow_partial_update', False)
    if ((res_dicts is None) and allow_partial_update):
        return
    resource_list = package.resources_all
    old_list = package.resources_all[:]
    obj_list = []
    for res_dict in (res_dicts or []):
        if ((not (u'package_id' in res_dict)) or (not res_dict[u'package_id'])):
            res_dict[u'package_id'] = package.id
        obj = resource_dict_save(res_dict, context)
        obj_list.append(obj)
    resource_list[:] = obj_list
    for resource in (set(old_list) - set(obj_list)):
        resource.state = 'deleted'
        resource_list.append(resource)
def package_resource_list_save(res_dicts, package, context):
    allow_partial_update = context.get('allow_partial_update', False)
    if ((res_dicts is None) and allow_partial_update):
        return
    resource_list = package.resources_all
    old_list = package.resources_all[:]
    obj_list = []
    for res_dict in (res_dicts or []):
        if ((not (u'package_id' in res_dict)) or (not res_dict[u'package_id'])):
            res_dict[u'package_id'] = package.id
        obj = resource_dict_save(res_dict, context)
        obj_list.append(obj)
    resource_list[:] = obj_list
    for resource in (set(old_list) - set(obj_list)):
        resource.state = 'deleted'
        resource_list.append(resource)