Merge lp://staging/~danilo/maas/django-upgrade-immutable-querydict into lp://staging/~maas-committers/maas/trunk

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 6101
Proposed branch: lp://staging/~danilo/maas/django-upgrade-immutable-querydict
Merge into: lp://staging/~maas-committers/maas/trunk
Prerequisite: lp://staging/~danilo/maas/django-upgrade-legacy-migrations
Diff against target: 259 lines (+60/-38)
9 files modified
src/maasserver/api/boot_resources.py (+1/-1)
src/maasserver/api/commissioning_scripts.py (+8/-6)
src/maasserver/api/dnsresourcerecords.py (+6/-5)
src/maasserver/api/dnsresources.py (+2/-2)
src/maasserver/api/scripts.py (+10/-8)
src/maasserver/forms/__init__.py (+9/-0)
src/maasserver/forms/ephemeral.py (+1/-1)
src/maasserver/forms/iprange.py (+2/-0)
src/maasserver/forms/script.py (+21/-15)
To merge this branch: bzr merge lp://staging/~danilo/maas/django-upgrade-immutable-querydict
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+325995@code.staging.launchpad.net

Commit message

Replace all in-place modifying of POST data which is immutable in more recent Django versions.

Description of the change

request.data contains QueryDict objects which have become immutable by default.

In most cases, it was sufficient to create a copy of the data on the API side before passing it on to the form processing machinery (or instantiating the form with it).

But for some reason that did not work that well in LicenseKeyForm: I had to modify the internal "_mutable" attribute to be able to edit the data in-place. The problem is how the data is processed there: it wants to allow API to pass in a combined osystem/distro_series in the distro_series field, thus combines those into one in full_clean(), and then clean() splits those up again. Officially, Django only supports overriding clean(), so we are basically playing with internals that we shouldn't be playing with. I am not sure how to best highlight this case. Perhaps an XXX?

This gets us down to 66 test failures with django 1.11 from ppa:danilo/django-1.11 and django-piston3 from ppa:danilo/django-piston3

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good overall. Just one comment on the section that should be of no surprise. ;-)

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Addressed the comment: after looking some more, I think I can fix this in a nicer way, but I'd rather do that as a separate branch since it requires test changes (which means more risk).

Revision history for this message
Данило Шеган (danilo) :
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Sounds good. Yeah that is much better.

The clean_osystem and clean_distro_series should not rely on each others filed values. When you need to validate two field together that should take place in the clean method.

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

This needs to wait for prereq before itcan land.

Follow-up branch up at https://code.launchpad.net/~danilo/maas/django-upgrade-licensekeyform-immutable-querydict/+merge/326079

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.