def handle(self, request, data):
        try:
            rules = json.loads(data["rules"])
            new_mapping = api.keystone.mapping_create(
                request,
                data["id"],
                rules=rules)
            messages.success(request,
                             _("Mapping created successfully."))
            return new_mapping
        except exceptions.Conflict:
            msg = _('Mapping ID "%s" is already used.') % data["id"]
            messages.error(request, msg)
        except (__HOLE__, ValueError):
            msg = _("Unable to create mapping. Rules has malformed JSON data.")
            messages.error(request, msg)
        except Exception:
            exceptions.handle(request,
                              _("Unable to create mapping."))
        return False
dataset/ETHPy150Open openstack/horizon/openstack_dashboard/dashboards/identity/mappings/forms.py/CreateMappingForm.handle