"""Defines how widgets are displayed in gazpacho"""fromlxml.etreeimportElementfromcollectionsimportdefaultdictfrom.entityimportget_entity_typeclassEntityDefinition(object):is_toplevel=Falsedef__init__(self,entity_name,gadget_type=None,editor_type=None,is_toplevel=False):self.new_item_counter=1self.entity_name=entity_nameself.gadget_type=gadget_typeself.editor_type=editor_typeself.is_toplevel=is_topleveldefcreate_entity(self):returnElement('object',**{'class':self.entity_name})classEntityCatalog(object):def__init__(self):self.entity_defs=defaultdict(list)self.entity_map={}defregister_entity_def(self,category,definition):self.entity_defs[category].append(definition)self.entity_map[definition.entity_name]=definitiondefget_entity_def(self,name):print'ged',name,self.entity_map.get(name)returnself.entity_map.get(name)entity_catalog=EntityCatalog()defget_entity_def(entity):returnentity_catalog.get_entity_def(get_entity_type(entity))