Set ``val`` as the :attr:`value` for this :class:`Setting`.

        If ``default`` is ``True`` set also the :attr:`default` value.

def set(self, val, default=False, imported=False):
        """Set ``val`` as the :attr:`value` for this :class:`Setting`.

        If ``default`` is ``True`` set also the :attr:`default` value.
        """
        if hasattr(self.validator, '__call__'):
            try:
                val = self.validator(val)
            except Exception as exc:
                raise type(exc)(
                    'Could not validate value for "%s" setting: %s' %
                    (self.name, exc)
                ) from None
        self.value = val
        self.imported = imported
        if default:
            self.default = val
        self.modified = True