def require_editable(f):
    """
    Makes sure the registry key is editable before trying to edit it.
    """

    def wrapper(self, *args, **kwargs):
        if not self._edit:
            raise RegistryKeyNotEditable("The key is not set as editable.")
        return f(self, *args, **kwargs)

    return wrapper