def __createTopic(self, nameTuple, desc, specGiven, parent=None): '''Actual topic creation step. Adds new Topic instance to topic map, and sends notification message (of topic 'pubsub.newTopic') about new topic having been created.''' if specGiven is None: specGiven = ArgSpecGiven() parentAI = None if parent: parentAI = parent._getListenerSpec() argsInfo = ArgsInfo(nameTuple, specGiven, parentAI) if (self.__treeConfig.raiseOnTopicUnspecified and not argsInfo.isComplete()): raise ListenerSpecIncomplete(nameTuple) newTopicObj = Topic(self.__treeConfig, nameTuple, desc, argsInfo, parent = parent) # sanity checks: assert not self._topicsMap.has_key(newTopicObj.getName()) if parent is self.__allTopics: assert len( newTopicObj.getNameTuple() ) == 1 else: assert parent.getNameTuple() == newTopicObj.getNameTuple()[:-1] assert nameTuple == newTopicObj.getNameTuple() # store new object and notify of creation self._topicsMap[ newTopicObj.getName() ] = newTopicObj self.__treeConfig.notificationMgr.notifyNewTopic( newTopicObj, desc, specGiven.reqdArgs, specGiven.argsDocs) return newTopicObj
def checkAllTopicsSpecifed(self): '''Check all topics that have been created and raise a ListenerSpecIncomplete exception if one is found that does not have a listener specification. ''' for topic in self._topicsMap.itervalues(): if not topic.isSendable(): raise ListenerSpecIncomplete(topic.getNameTuple())