def getContent(self): an = IAnnotationManager(self.context) try: content = an.read() except: content = {'qaherit': 'False', 'qatext': '', 'qalinks': ''} return content
def update(self): self.activate = True try: an = IAnnotationManager(self.context) except: self.activate = False if self.activate: content = self.readQA(self.context) if content['qatext'] == None: content['qatext'] = '' if content['qalinks'] == None: content['qalinks'] = '' if content['qalinks'] != '': self.activate = True self.qaLinksList = [] self.qaherit = content['qaherit'] self.qatext = content['qatext'] for linkline in content['qalinks'].split("\n"): link = linkline.split(';')[0] url = linkline.split(';')[1] self.qaLinksList.append({'link': link, 'url': url}) else: self.activate = False else: self.activate = False
def readQA(self, object2read): annotable = True try: an = IAnnotationManager(object2read) except: annotable = False if annotable: isAnnotation = True try: content = an.read() except: isAnnotation = False if isAnnotation: # CAS d'arrive au repertoire racine if object2read.id == 'Plone' and content['qalinks'] != '': return content if content['qaherit'] == True: return self.readQA(aq_inner(object2read).aq_parent) else: return content else: if object2read.id == 'Plone': content = {'qaherit': False, 'qatext': '', 'qalinks': ''} return content return self.readQA(aq_inner(object2read).aq_parent) else: content = {'qaherit': False, 'qatext': '', 'qalinks': ''} return content
def save(self, action): data, errors = self.extractData() if errors: return an = IAnnotationManager(self.context) try: an.write(data) except ValueError: IStatusMessage(self.context).add('Error in data')