

def handle(self, request, context):
    namespace_name = self.initial['id']
    current_names = self.get_names(self.initial['resource_types'])
    try:
        updated_types = json.loads(self.data['resource_types'])
        selected_types = [updated_type for updated_type in updated_types if updated_type.pop('selected', False)]
        for current_name in current_names:
            glance.metadefs_namespace_remove_resource_type(self.request, namespace_name, current_name)
        for selected_type in selected_types:
            selected_type.pop('$$hashKey', None)
            selected_type.pop('created_at', None)
            selected_type.pop('updated_at', None)
            glance.metadefs_namespace_add_resource_type(self.request, namespace_name, selected_type)
        msg = _('Resource types updated for namespace %s.')
        msg %= namespace_name
        messages.success(request, msg)
    except Exception:
        msg = _('Error updating resource types for namespace %s.')
        msg %= namespace_name
        exceptions.handle(request, msg)
        return False
    return True

dataset/ETHPy150Open openstack/horizon/openstack_dashboard/dashboards/admin/metadata_defs/forms.py ManageResourceTypesForm.handle/original