From: Fredrik Tolf Date: Fri, 24 Jul 2015 13:25:01 +0000 (+0200) Subject: Fixed storedescs to work properly on derived types. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=36c0a0110bb357edb6c167e9abc1a689106c3f05;p=didex.git Fixed storedescs to work properly on derived types. --- diff --git a/didex/store.py b/didex/store.py index 43c1348..55dc71e 100644 --- a/didex/store.py +++ b/didex/store.py @@ -1,4 +1,4 @@ -import threading, pickle +import threading, pickle, inspect from . import db, index, cache from .db import txnfun @@ -35,13 +35,14 @@ class storedesc(object): def storedescs(obj): t = type(obj) - ret = getattr(t, "__didex_attr", None) + ret = t.__dict__.get("__didex_attr") if ret is None: ret = [] - for nm, val in t.__dict__.items(): - if isinstance(val, storedesc): - ret.append((nm, val)) - t.__didex_attr = ret + for st in inspect.getmro(t): + for nm, val in st.__dict__.items(): + if isinstance(val, storedesc): + ret.append((nm, val)) + t.__dict__["__didex_attr"] = ret return ret class datastore(object):