From 36c0a0110bb357edb6c167e9abc1a689106c3f05 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Fri, 24 Jul 2015 15:25:01 +0200 Subject: [PATCH 1/1] Fixed storedescs to work properly on derived types. --- didex/store.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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): -- 2.11.0