diff options
Diffstat (limited to 'keystone/common')
| -rw-r--r-- | keystone/common/sql/core.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/keystone/common/sql/core.py b/keystone/common/sql/core.py index c18bf83d..0bd0000d 100644 --- a/keystone/common/sql/core.py +++ b/keystone/common/sql/core.py @@ -68,10 +68,21 @@ class DictBase(object): return cls(**new_d) - def to_dict(self): + def to_dict(self, include_extra_dict=False): + """Returns the model's attributes as a dictionary. + + If include_extra_dict is True, 'extra' attributes are literally + included in the resulting dictionary twice, for backwards-compatibility + with a broken implementation. + + """ d = self.extra.copy() for attr in self.__class__.attributes: d[attr] = getattr(self, attr) + + if include_extra_dict: + d['extra'] = self.extra.copy() + return d def __setitem__(self, key, value): |
