Merge lp:~mpontillo/maas/device-api-1566109 into lp:~maas-committers/maas/trunk
Proposed by
Mike Pontillo
Status: | Merged |
---|---|
Approved by: | Mike Pontillo |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4937 |
Proposed branch: | lp:~mpontillo/maas/device-api-1566109 |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
160 lines (+92/-4) 4 files modified
src/maasserver/api/tests/test_devices.py (+18/-0) src/maasserver/forms.py (+8/-0) src/maasserver/tests/test_forms_device.py (+64/-2) src/maasserver/utils/forms.py (+2/-2) |
To merge this branch: | bzr merge lp:~mpontillo/maas/device-api-1566109 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mike Pontillo (community) | Approve | ||
Gavin Panella (community) | Approve | ||
Review via email: mp+291580@code.launchpad.net |
Commit message
Ensure QueryDict is always used with WithMACAddresse
* This is the likely fix for bug #1566109.
To post a comment you must log in.
There's a problem in WithMACAddresse sMixin that illustrates one of my
pet hates.
I want to pass a MultiValueDict into the form's constructor, so that sMixin.
self.data has a getlist() method. This is used by WithMACAddresse
However, Django's BaseForm has the following code:
class BaseForm(object):
def __init__(self, data=None, ...):
...
self.data = data or {}
...
so when I pass an *empty* MultiValueDict in — which is an ancestor of
QueryDict, the container that Django uses to convey request arguments to
handlers, and thus a perfectly reasonable thing to pass into a form —
it's replaced with a plain old Python dict, and subsequent attempts to
use getlist() on it break with AttributeError.
All because someone was too f***ing lazy test against None:
self.data = {} if data is None else data
My blood boils. Implicit boolean-ness is a curse.