Unset fields of API objects have None values instead of wsme.types.Unset

Bug #1385247 reported by Vladyslav Drok
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
Low
Vladyslav Drok

Bug Description

In API objects constructors, e.g. in Node, fields initialization is done this way:

for k in fields:
    # Skip fields we do not expose.
    if not hasattr(self, k):
        continue
    self.fields.append(k)
    setattr(self, k, kwargs.get(k))

So, the field is set to None if it is passed to __init__ as None and if it is not passed at all.
If it's not passed at all it's better to use wsme.types.Unset instead of None, as it is its purpose:

setattr(self, k, kwargs.get(k, wsme.types.Unset))

so that these two cases can be distinguished.

Vladyslav Drok (vdrok)
Changed in ironic:
assignee: nobody → Vladyslav Drok (vdrok)
Dmitry Tantsur (divius)
Changed in ironic:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

Fix proposed to branch: master
Review: https://review.openstack.org/131139

Changed in ironic:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (master)

Reviewed: https://review.openstack.org/131139
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=645072bfa3da8c63b6e469021db334b8d7586416
Submitter: Jenkins
Branch: master

commit 645072bfa3da8c63b6e469021db334b8d7586416
Author: Vladyslav Drok <email address hidden>
Date: Mon Oct 27 15:09:45 2014 +0200

    Use wsme.Unset as default value for API objects

    wsme.Unset should be used instead of None as default value for API
    objects as None is valid value that could be passed to constructor.

    Closes-bug: #1385247
    Change-Id: I94f6dd14a7befe217552cf2c6998bb1c1d2d338d

Changed in ironic:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ironic:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ironic:
milestone: kilo-1 → 2015.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.