diff options
author | Michaël Ball <michael.ball@gmail.com> | 2017-03-26 10:19:59 +0100 |
---|---|---|
committer | Michaël Ball <michael.ball@gmail.com> | 2017-06-04 07:37:53 +0100 |
commit | d06f96388d754ed41876f7fccb63f84241d44963 (patch) | |
tree | 640a4f3eaf7e1f2b76a246a1977c27775d0b59a1 /models/base.py | |
parent | caa1c3ccdf94ee20140b3964aab0ad3058e03699 (diff) |
Works on python 2/pypy
Diffstat (limited to 'models/base.py')
-rw-r--r-- | models/base.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/models/base.py b/models/base.py index fd40001..8a6fc47 100644 --- a/models/base.py +++ b/models/base.py @@ -1,10 +1,15 @@ -class BaseModel(): +"""Implements a base model for other models to inherit.""" +from six import iteritems + +class BaseModel(object): + """BaseModel is meant to be inherited by other models.""" def as_dict(self): + """Exposes all the object's values as a dict.""" this_dict = {} - for k in self.__dict__.keys(): - if k != "_db": - this_dict[k] = getattr(self, k) + for key, val in iteritems(self.__dict__): + if key != "_db": + this_dict[key] = val return this_dict |