[PATCH] Do not bypass name setters in the custom spoke. (#1138370)
Vratislav Podzimek
vpodzime at redhat.com
Wed Jan 7 07:50:19 UTC 2015
On Tue, 2015-01-06 at 14:21 -0600, David Lehman wrote:
> This way we get the validation provided by the setters.
> ---
> pyanaconda/ui/gui/spokes/custom.py | 36 +++++++++++++++++++++++++-----------
> 1 file changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
> index c626979..ff33a88 100644
> --- a/pyanaconda/ui/gui/spokes/custom.py
> +++ b/pyanaconda/ui/gui/spokes/custom.py
> @@ -1220,14 +1220,20 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
> #
> if changed_name:
> self.clear_errors()
> - use_dev._name = name
> - new_name = use_dev.name
> - log.debug("changing name of %s to %s", old_name, new_name)
> - if new_name in self._storage_playground.names:
> - use_dev._name = old_name
> - self.set_info(_("Specified name %s already in use.") % new_name)
> + try:
> + use_dev.name = name
> + except ValueError as e:
> + self._error = e
> + self.set_error(_("Invalid device name: %s") % name)
> + self.window.show_all()
> else:
> - updateSelectorFromDevice(selector, device)
> + new_name = use_dev.name
> + log.debug("changing name of %s to %s", old_name, new_name)
> + if new_name in self._storage_playground.names:
> + use_dev.name = old_name
> + self.set_info(_("Specified name %s already in use.") % new_name)
> + else:
> + updateSelectorFromDevice(selector, device)
>
> self._populate_right_side(selector)
>
> @@ -2114,10 +2120,18 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
> self._storage_playground.devicetree.names.remove(container.name)
> self._storage_playground.devicetree.names.append(self._device_container_name)
>
> - # until there's a setter for btrfs volume name
> - container._name = self._device_container_name
> - if container.format.type == "btrfs":
> - container.format.label = self._device_container_name
> + try:
> + container.name = self._device_container_name
> + except ValueError as e:
> + self._error = e
> + self.set_error(_("Invalid device name: %s") % self._device_container_name)
> + self.window.show_all()
> + self._device_container_name = container_name
> + self._on_update_settings_clicked(None)
> + return
> + else:
> + if container.format.type == "btrfs":
> + container.format.label = self._device_container_name
>
> container_exists = getattr(container, "exists", False)
This also looks good.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list