def METHOD_NAME(obj, event):
    """Additional configuration when the ``enable_self_reg``
    setting is updated in the ``Security```control panel.
    If the setting is enabled, the ``Add portal member`` permission is
    added to ``Anonymous`` role to allow self registration for anonymous
    users. If the setting is disabled, this permission is removed.
    """
    if event.record.fieldName != "enable_self_reg":
        return
    portal = getSite()
    value = event.newValue
    app_perms = portal.rolesOfPermission(permission="Add portal member")
    reg_roles = []
    for app_perm in app_perms:
        if app_perm["selected"] == "SELECTED":
            reg_roles.append(app_perm["name"])
    if value is True and "Anonymous" not in reg_roles:
        reg_roles.append("Anonymous")
    if value is False and "Anonymous" in reg_roles:
        reg_roles.remove("Anonymous")
    portal.manage_permission("Add portal member", roles=reg_roles, acquire=0)