From d06f96388d754ed41876f7fccb63f84241d44963 Mon Sep 17 00:00:00 2001 From: Michaƫl Ball Date: Sun, 26 Mar 2017 10:19:59 +0100 Subject: Works on python 2/pypy --- models/base.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'models/base.py') 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 -- cgit v1.2.3