def get_links_by_section(self, section): context = self.context if IAnnotatedLinkList.providedBy(self.context): links = context.Schema().getField('annotatedlinklist').get(context) return [i for i in links if i["section"] == section] else: return None
def __init__(self, context): self.context = context if IAnnotatedLinkList.providedBy(context): self._fields.append( extended_fields_dict.get('annotatedlinklist').copy() ) self._generateMethods(context, self._fields)
def run(self): # This script must be customised before running raise Exception def log(message): self.REQUEST.response.write(str(message) + "\n") def get_translation_obs(ob): return [i[0] for i in ob.getTranslations().values()] subtyper = component.getUtility(ISubtyper) portal = self.portal_url.getPortalObject() fop_root = portal.en.oshnetwork["focal-points"] countries = [ i for i in fop_root.objectIds() if fop_root[i].portal_type == "Folder" ] countries = ['slovakia'] for country in countries: fop = fop_root[country] doc = fop.get("index_html", None) if doc: # [log(i) for i in providedBy(doc)] # log(IAnnotatedLinkList.providedBy(doc)) for translation in get_translation_obs(doc): type = subtyper.existing_type(doc) # log("%s : %s" %(translation.absolute_url(), type)) if not IAnnotatedLinkList.providedBy(translation): log("ERROR %s : %s" % (translation.absolute_url(), type)) subtyper.change_type(translation, 'annotatedlinks') log("Updated %s" % translation.absolute_url()) transaction.commit() #if type and type.name == 'annotatedlinks': # try: # subtyper.remove_type(translation) # except: # pass #subtyper.change_type(translation, 'annotatedlinks') # log("Updated %s" %translation.absolute_url()) # transaction.commit() else: log("ERROR index_html is missing %s" % fop.absolute_url())
def run(self): # This script must be customised before running raise Exception def log(message): self.REQUEST.response.write(str(message)+"\n") def get_translation_obs(ob): return [i[0] for i in ob.getTranslations().values()] subtyper = component.getUtility(ISubtyper) portal = self.portal_url.getPortalObject() fop_root = portal.en.oshnetwork["focal-points"] countries = [i for i in fop_root.objectIds() if fop_root[i].portal_type == "Folder"] countries = ['slovakia'] for country in countries: fop = fop_root[country] doc = fop.get("index_html", None) if doc: # [log(i) for i in providedBy(doc)] # log(IAnnotatedLinkList.providedBy(doc)) for translation in get_translation_obs(doc): type = subtyper.existing_type(doc) # log("%s : %s" %(translation.absolute_url(), type)) if not IAnnotatedLinkList.providedBy(translation): log("ERROR %s : %s" %(translation.absolute_url(), type)) subtyper.change_type(translation, 'annotatedlinks') log("Updated %s" %translation.absolute_url()) transaction.commit() #if type and type.name == 'annotatedlinks': # try: # subtyper.remove_type(translation) # except: # pass #subtyper.change_type(translation, 'annotatedlinks') # log("Updated %s" %translation.absolute_url()) # transaction.commit() else: log("ERROR index_html is missing %s" %fop.absolute_url())
def get_links(self, obj): if IAnnotatedLinkList.providedBy(obj): return obj.annotatedlinklist
def has_links(self): """ Check if this page has been subtyped to provide annotated links """ context = self.context return IAnnotatedLinkList.providedBy(context) and \ context.Schema().getField('annotatedlinklist').get(context)