def get_health(self): #return self._health stateAdapter = IState(self) stateNum = stateAdapter.getStateOverview(-1) if stateNum == 0: return 1.0 elif stateNum == 1: return 0.5 elif stateNum == 2: return 0.0 else: return None return None
def getStateIcon(item, formatter): """State Icon of Object""" resource_path = getAdapter(formatter.request, name='pics')() try: icon_name = IState(item).getIconName() except Exception, errtxt: icon_name = u"Blank_gray.png"
def traverse4RptPre(self, level, comments, autoAppend=True): """pdf report object preamble level: indent-level (int 0..) comments: should there comments are in the output? """ if self.document is not None: elemList = ParentRptPdf.traverse4RptPre(\ self, level, comments, autoAppend) if elemList is None: elemList = [] try: stateDict = IState(self.context).getStateDict() if stateDict['overview'] == 'error': myStyle = self.document.styles['ErrorBox'] elif stateDict['overview'] == 'warn': myStyle = self.document.styles['WarnBox'] else: myStyle = None if myStyle is not None: para = RptPara(stateDict['warnings'][0], style=myStyle, doc=self.document) elemList.extend( [Spacer(0, 4 * mm), para, Spacer(0, 4 * mm)]) except TypeError: pass if autoAppend is True: #comp = KeepTogether(elemList) #self.document.append(comp) for elem in elemList: self.document.append(elem) else: return elemList return None
def state(self): """ gives us the state dict of the object """ return IState(self.context).getStateDict()