sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #05497
Re: [Merge] ~ack/maas:macaddress-field-rework into maas:master
Diff comments:
> diff --git a/src/maasserver/fields.py b/src/maasserver/fields.py
> index 276d4d4..7c79687 100644
> --- a/src/maasserver/fields.py
> +++ b/src/maasserver/fields.py
> @@ -50,19 +72,17 @@ class MACAddressFormField(forms.CharField):
> )
>
>
> -class MACAddressField(Field):
> +class MACAddressField(TextField):
> """Model field type: MAC address."""
>
> description = "MAC address"
>
> default_validators = [MAC_VALIDATOR]
>
> - def db_type(self, *args, **kwargs):
> - return "macaddr"
> -
> - def get_prep_value(self, value):
> - # Convert empty string to None.
> - return super().get_prep_value(value) or None
> + def to_python(self, value):
> + if not value:
> + return value
> + return normalise_macaddress(value)
That should be possible, although it's likely a bigger change. Right now we rely on the `macaddr` field to support input in various formats and always return the colon-separated version, to achieve the same we need to ensure we call `normalise_macaddr` all the right places.
I can take a look at doing it that way, I'm also not happy about keeping a custom field.
>
>
> class XMLField(Field):
--
https://code.launchpad.net/~ack/maas/+git/maas/+merge/438041
Your team MAAS Committers is subscribed to branch maas:master.
References