From bb0ddc999fa484a016470cbe09a774ab0b6633af Mon Sep 17 00:00:00 2001 From: florent <florent@laas.fr> Date: Sun, 24 Oct 2010 21:53:37 +0200 Subject: [PATCH] Register Entity classes in modules from which they are imported * src/dynamic_graph/entity.py. --- src/dynamic_graph/entity.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/dynamic_graph/entity.py b/src/dynamic_graph/entity.py index f3e7e12..53a31fe 100644 --- a/src/dynamic_graph/entity.py +++ b/src/dynamic_graph/entity.py @@ -5,7 +5,7 @@ """ import wrap, signal_base -entityList = [] +entityClassNameList = [] def initEntity(self, name): """ @@ -13,9 +13,9 @@ def initEntity(self, name): """ Entity.__init__(self, self.class_name, name) -def updateEntityClasses(): - entityTypeList = wrap.factory_get_entity_class_list() - for e in entityTypeList: +def updateEntityClasses(dictionary): + cxx_entityList = wrap.factory_get_entity_class_list() + for e in filter(lambda x: not x in entityClassNameList, cxx_entityList): class metacls(type): def __new__(mcs, name, bases, dict): return type.__new__(mcs, name, bases, dict) @@ -24,11 +24,12 @@ def updateEntityClasses(): a = metacls(e, (Entity,), {}) # Store class name in class member a.class_name = e - print ("new class %s"%e) # set class constructor setattr(a, '__init__', initEntity) # Store new class in dictionary with class name - globals()[e] = a + dictionary[e] = a + # Store class name in local list + entityClassNameList.append(e) class Entity (object) : -- GitLab