add a way to instantiate an object from a dict of its fields values
This commit is contained in:
parent
62adf86daa
commit
dd8bf4fa2f
1 changed files with 9 additions and 0 deletions
|
|
@ -474,6 +474,15 @@ class BaseObject(object):
|
|||
fields_iterator = self.iter_fields()
|
||||
return OrderedDict(iter_decorate(fields_iterator))
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, values, backend=None):
|
||||
self = cls()
|
||||
|
||||
for attr in values:
|
||||
setattr(self, attr, values[attr])
|
||||
|
||||
return self
|
||||
|
||||
|
||||
class Currency(object):
|
||||
CURRENCIES = {u'EUR': u'€',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue