From f1c4b8e5f34eb6b5e70da6711750dcf05cea8c0a Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 26 Jun 2013 09:51:12 -0700 Subject: Add update() method to NovaObject for dict compatibility In order for objects to behave like dicts, they need to support the update() method. This patch adds that. Related to blueprint unified-object-model Change-Id: Icb3932682285cbf8e7362e5b748e42a754b17fe7 --- nova/objects/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nova/objects/base.py b/nova/objects/base.py index 4f973de0c..c6dc8cc1a 100644 --- a/nova/objects/base.py +++ b/nova/objects/base.py @@ -367,6 +367,14 @@ class NovaObject(object): """ return self[key] + def update(self, updates): + """For backwards-compatibility with dict-base objects. + + NOTE(danms): May be removed in the future. + """ + for key, value in updates.items(): + self[key] = value + class ObjectListBase(object): """Mixin class for lists of objects. -- cgit