def updateLayout(self, ppath='', all=False, portals='', p_action='ep', sel_skin='', locator='skin', f_action='af', file_id='', REQUEST=None): """ update files for Naaya layout """ report = {} portals_custom = [] for portal_id in portals.split(','): portals_custom.append(portal_id.strip()) if all: portals_list = get_portals(self, self.pmeta_types) for portal in portals_list: do_update = False if p_action == 'ep': if not portal.id in portals_custom: do_update = True else: if portal.id in portals_custom: do_update = True if do_update: report[portal.id] = self.updateLayoutForms(portal, locator, sel_skin, f_action, file_id) else: portal = get_portal(self, ppath) if not portal.id in portals_custom: report[portal.id] = self.updateLayoutForms(portal, locator, sel_skin, f_action, file_id) REQUEST.SESSION.set('report', report) return REQUEST.RESPONSE.redirect('%s/update_layout_html' % self.absolute_url())
def _list_updates(self): """ Return all portals that need update """ utool = self.aq_inner.aq_parent portals = get_portals(self) for portal in portals: if not self._verify_doc(portal): continue yield portal
def get_report(self, forms, portals='', exclude=False, REQUEST=None): if not REQUEST.has_key('show_report'): # TODO: remove this return report = {} forms = convertLinesToList(forms) portals_list = get_portals(self) portals_custom = [] if portals.strip(): for portal_id in portals.split(','): portals_custom.append(portal_id.strip()) for portal in portals_list: if portals_custom: if exclude and portal.id in portals_custom: continue elif not exclude and portal.id not in portals_custom: continue portal_path = '/'.join(portal.getPhysicalPath()[1:]) portal_forms = portal.portal_forms if forms: forms_list_tmp = [] for form_line in forms: #Search in ZMI and FS for template patterns for form_id in self.find_templates(re.compile(form_line), portal): if form_id not in forms_list_tmp: forms_list_tmp.append(form_id) forms_list = forms_list_tmp del(forms_list_tmp) else: forms_list = portal_forms.objectIds() deltas = [] for form_id in forms_list: try: form_fs = portal_forms._default_form(form_id) except KeyError, exc_error: zLOG.LOG('Naaya Updater', zLOG.ERROR, '%s: %s' % (portal.id, exc_error)) continue form_zmi = portal_forms._getOb(form_id) if form_fs and form_zmi: t1 = normalize_template(form_fs._text) t2 = normalize_template(form_zmi._text) delta = { 'physical_path': '/'.join(form_zmi.getPhysicalPath()[1:]), 'absolute_url': form_zmi.absolute_url(), 'id': form_zmi.getId(), 'title': form_zmi.title_or_id(), } if t1 == t2: delta['result'] = 'identical' else: delta['result'] = 'different' delta['diff'] = html_diff(form_fs._text, form_zmi._text) deltas.append(delta) if len(deltas) > 0: report[portal_path] = deltas
def _list_updates(self): """ Return all objects that need update""" utool = self.aq_inner.aq_parent portals = get_portals(self) for portal in portals: for survey in portal.getCatalogedObjects(meta_type='Naaya Mega Survey'): if not self._verify_doc(survey): continue yield survey
def _list_updates(self): """ Return all objects that need update""" utool = self.aq_inner.aq_parent portals = get_portals(self) for portal in portals: for survey in portal.getCatalogedObjects( meta_type='Naaya Mega Survey'): if not self._verify_doc(survey): continue yield survey
def find_schema_differences(self): """ Searches for schema properties that differ from their definition in their content code """ content_types = get_pluggable_content().values() portals = get_portals(self) missing_properties = {} modified_properties = {} for portal in portals: schema = portal._getOb(ID_SCHEMATOOL, None) if schema: modified_properties[portal] = self.find_modified_schema_properties(content_types, schema) missing_properties[portal] = self.find_missing_schema_properties(content_types, schema) return {'missing_properties': missing_properties, 'modified_properties': modified_properties}
def pre_update_hook(self): """ """ portals = get_portals(self) portlets = [(portal, self.portal_portlet(portal)) for portal in portals] unique_sections = [] portals_per_sections = [] portals_sections = {} for portal_port in portlets: portal, portlet = portal_port if not hasattr(portlet, 'portlet'): markup = portlet.read() lines = markup.split('\n') portlet_text_only = self.get_texts(markup) sections = [] for line in lines: for section in portlet_text_only: section_details = () if ('>' + section + '</a>') in line and '<li' in line: section_details = (lines.index(line), section) sections.append(section_details) if sections not in unique_sections: unique_sections.append(sections) portals_sections[''.join(portal.getPhysicalPath())] = sections for section in unique_sections: section_portals = [] for portal in portals_sections: if portals_sections[portal] == section: section_portals.append(portal) portals_per_sections.append(section_portals) return { 'unique_sections': unique_sections, 'portals_per_sections': portals_per_sections }
def pre_update_hook(self): """ """ portals = get_portals(self) portlets = [(portal, self.portal_portlet(portal)) for portal in portals] unique_sections = [] portals_per_sections = [] portals_sections = {} for portal_port in portlets: portal, portlet = portal_port if not hasattr(portlet, 'portlet'): markup = portlet.read() lines = markup.split('\n'); portlet_text_only = self.get_texts(markup) sections = [] for line in lines: for section in portlet_text_only: section_details = () if ('>' + section + '</a>') in line and '<li' in line: section_details = (lines.index(line), section) sections.append(section_details) if sections not in unique_sections: unique_sections.append(sections) portals_sections[''.join(portal.getPhysicalPath())] = sections for section in unique_sections: section_portals = [] for portal in portals_sections: if portals_sections[portal] == section: section_portals.append(portal) portals_per_sections.append(section_portals) return { 'unique_sections': unique_sections, 'portals_per_sections': portals_per_sections }
def updateLayout(self, ppath='', all=False, portals='', p_action='ep', sel_skin='', locator='skin', f_action='af', file_id='', REQUEST=None): """ update files for Naaya layout """ report = {} portals_custom = [] for portal_id in portals.split(','): portals_custom.append(portal_id.strip()) if all: portals_list = get_portals(self, self.pmeta_types) for portal in portals_list: do_update = False if p_action == 'ep': if not portal.id in portals_custom: do_update = True else: if portal.id in portals_custom: do_update = True if do_update: report[portal.id] = self.updateLayoutForms( portal, locator, sel_skin, f_action, file_id) else: portal = get_portal(self, ppath) if not portal.id in portals_custom: report[portal.id] = self.updateLayoutForms( portal, locator, sel_skin, f_action, file_id) REQUEST.SESSION.set('report', report) return REQUEST.RESPONSE.redirect('%s/update_layout_html' % self.absolute_url())
def reinstallMetaTypes(self, all=False, ppath='', portals='', p_action='ep', contenttypes='', ct_action='ect', REQUEST=None): """ reinstall active metatypes for Naaya portals""" report = {} portals_custom = [] for portal_id in portals.split(','): portals_custom.append(portal_id.strip()) if all: portals_list = get_portals(self, self.pmeta_types) for portal in portals_list: do_update = False if p_action == 'ep': if not portal.id in portals_custom: do_update = True else: if portal.id in portals_custom: do_update = True if do_update: report[portal.id] = self.reloadMetaTypesForms( portal, contenttypes, ct_action) else: portal = get_portal(ppath) if not portal.id in portals_custom: report[portal.id] = self.reloadMetaTypesForms( portal, contenttypes, ct_action) if not REQUEST: return report REQUEST.SESSION.set('report', report) return REQUEST.RESPONSE.redirect(self.absolute_url())
def get_portal_output(): for portal in get_portals(self): if portal_ids and portal.id not in portal_ids: continue yield (portal.absolute_url(1), list_portal_objects(portal))