diff options
| author | Dolph Mathews <dolph.mathews@gmail.com> | 2012-11-06 17:01:59 +0000 |
|---|---|---|
| committer | Dolph Mathews <dolph.mathews@gmail.com> | 2012-11-06 17:01:59 +0000 |
| commit | df148a09fc1c7d44f2134a2dc6566ef1dbe772df (patch) | |
| tree | e1f3d95563ba26f43c82a9bfcc0c5055943a8fb6 /keystone/common | |
| parent | a6ef09d94300718197a4fa8757fd3a7a45876963 (diff) | |
Return non-indexed attrs, not 'extra' (bug 1075376)
(most of this is pulled from the v3 branch)
Change-Id: Id1118e7a2b245fb7ec95e41ec297c87036953db2
Diffstat (limited to 'keystone/common')
| -rw-r--r-- | keystone/common/sql/core.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/keystone/common/sql/core.py b/keystone/common/sql/core.py index 27df8914..1a9d595f 100644 --- a/keystone/common/sql/core.py +++ b/keystone/common/sql/core.py @@ -57,9 +57,22 @@ class JsonBlob(sql_types.TypeDecorator): class DictBase(object): + attributes = [] + + @classmethod + def from_dict(cls, d): + new_d = d.copy() + + new_d['extra'] = dict((k, new_d.pop(k)) for k in d.iterkeys() + if k not in cls.attributes and k != 'extra') + + return cls(**new_d) def to_dict(self): - return dict(self.iteritems()) + d = self.extra.copy() + for attr in self.__class__.attributes: + d[attr] = getattr(self, attr) + return d def __setitem__(self, key, value): setattr(self, key, value) |
