def _update(self, portal):
        t = '%(info)s folder: <a href="%(url)s/manage_main">%(text)s</a>'
        pt_start = '<metal:block metal:define-macro="page" metal:extend-macro="here/standard_template_macro">'
        old_meta_slot = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" ?/>'
        meta_slot_start = '<metal:block fill-slot="meta">'
        meta_slot = '''
<metal:block fill-slot="meta">
    <meta tal:define="description here/description;
                      content python:here.html2text(description);"
          tal:condition="content"
          tal:attributes="content content" name="description" />
    <meta tal:condition="here/keywords"
          tal:attributes="content here/keywords" name="keywords" />
    <meta tal:attributes="content here/contributor" name="author" />
    <meta tal:attributes="content here/gl_get_selected_language"
          name="dc.language" />
    <meta tal:attributes="content string:${here/title} | ${here/site_title}"
          name="title" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</metal:block>
'''

        self.log.debug(physical_path(portal))
        for folder in list_folders_with_custom_index(portal):
            tal = folder.index.read()
            if re.search(meta_slot_start, tal) is not None:
                self.log.info(
                    t % {
                        'info': 'already has meta slot',
                        'url': folder.absolute_url(),
                        'text': physical_path(folder)
                    })
                continue

            if re.search('^' + pt_start, tal) is None and re.search(
                    old_meta_slot, tal) is None:
                self.log.info(
                    t % {
                        'info':
                        'not using standard template macro and no old meta slot',
                        'url': folder.absolute_url(),
                        'text': physical_path(folder)
                    })
                continue

            self.log.info(
                t % {
                    'info': 'matched',
                    'url': folder.absolute_url(),
                    'text': physical_path(folder)
                })

            if re.search(old_meta_slot, tal) is not None:
                # replace only first occurance, remove the others
                tal = re.sub(old_meta_slot, meta_slot, tal, count=1)
                tal = re.sub(old_meta_slot, '', tal)
            elif re.search('^' + pt_start, tal) is not None:
                tal = re.sub(pt_start, '%s\n%s' % (pt_start, meta_slot), tal)
            folder.index.write(tal)
        return True
    def _update(self, portal):
        start = '<span tal:replace="structure here/standard_html_header" ?/>'
        end = '<span tal:replace="structure here/standard_html_footer" ?/>'

        replace_start = '<metal:block metal:define-macro="page" metal:extend-macro="here/standard_template_macro">\n\n<metal:block metal:fill-slot="body">'
        replace_end = "</metal:block>\n\n</metal:block>"

        self.log.debug(physical_path(portal))
        for folder in list_folders_with_custom_index(portal):
            folder.index.expand = 0

            tal = folder.index.read()
            tal = tal.strip()

            if re.search("^" + start, tal) is None:
                assert re.search(end + "$", tal) is None
                continue
            assert re.search(end + "$", tal) is not None

            t = 'matched folder: <a href="%(url)s/manage_main">%(text)s</a>'
            self.log.info(t % {"url": folder.absolute_url(), "text": physical_path(folder)})

            tal = re.sub(start, replace_start, tal)
            tal = re.sub(end, replace_end, tal)

            folder.index.write(tal)
        return True
    def _update(self, portal):
        self.log.debug(physical_path(portal))
        objects = portal.ZopeFind(portal, obj_metatypes=['Page Template', 'Naaya Template'], search_sub=1)

        original1 = '<metal:block fill-slot="title">'
        original2 = '<metal:block metal:fill-slot="title">'

        target = '<metal:block metal:fill-slot="header-title">'

        t_found = 'Found duplicate title slot in: <a href="%(url)s/manage_main">%(text)s</a>'
        t_notfound = 'Not found %(text)s'

        for obj_id, obj in objects:
            tal = obj.read()

            ret = False
            if tal.find(original1) != -1:
                tal = tal.replace(original1, target)
                ret = True
            if tal.find(original2) != -1:
                tal = tal.replace(original2, target)
                ret = True

            if ret:
                self.log.info(t_found % {'url': '%s' % obj.absolute_url(),
                                   'text': '%s:%s' % (physical_path(obj), obj.meta_type) })
            else:
                self.log.info(t_notfound % {'url': '%s' % obj.absolute_url(),
                                   'text': '%s:%s' % (physical_path(obj), obj.meta_type) })


            obj.write(tal)

        return True
 def convert_publicinterface_to_custom_index(self, folder):
     if hasattr(folder, 'publicinterface'):
         self.log.debug('%s has publicinterface', physical_path(folder))
         if folder.publicinterface:
             self.log.debug('%s has custom index', physical_path(folder))
             folder.custom_index = 'local:index'
         del folder.publicinterface
 def convert_publicinterface_to_custom_index(self, folder):
     if hasattr(folder, 'publicinterface'):
         self.log.debug('%s has publicinterface', physical_path(folder))
         if folder.publicinterface:
             self.log.debug('%s has custom index', physical_path(folder))
             folder.custom_index = 'local:index'
         del folder.publicinterface
    def _update(self, portal):
        self.log.debug(physical_path(portal))

        t = 'folder index: <a href="%(url)s/manage_main">%(text)s</a>'
        for folder in list_folders_with_custom_index(portal):
            self.log.info(t % {'url': folder.absolute_url(),
                               'text': physical_path(folder)})

        return True
    def _update(self, portal):
        t = '%(info)s folder: <a href="%(url)s/manage_main">%(text)s</a>'

        old_macro_start = '<metal:block use-macro="here/folder_listing/macros/content">'
        new_macro_start = '<metal:block use-macro="python:here.getFormsTool().getForm(\'folder_listing\').macros[\'listing\']">'

        self.log.debug(physical_path(portal))
        for folder in list_folders_with_custom_index(portal):
            tal = folder.index.read()
            if tal.find(new_macro_start) != -1:
                self.log.info(
                    t % {
                        'info': 'already uses new folder listing macro',
                        'url': folder.absolute_url(),
                        'text': physical_path(folder)
                    })
                continue

            if tal.find(old_macro_start) == -1:
                self.log.info(
                    t % {
                        'info': 'not using folder listing macro',
                        'url': folder.absolute_url(),
                        'text': physical_path(folder)
                    })
                continue

            self.log.info(
                t % {
                    'info': 'replacing folder listing macro',
                    'url': folder.absolute_url(),
                    'text': physical_path(folder)
                })

            tal = tal.replace(old_macro_start, new_macro_start)
            folder.index.write(tal)

        custom_folder_index = portal.portal_forms._getOb('folder_index',
                                                         default=None)
        if custom_folder_index is None:
            return True

        tal = custom_folder_index.read()
        if tal.find(new_macro_start) != -1:
            self.log.info('folder index already uses new folder listing macro')
            return True

        if tal.find(old_macro_start) == -1:
            self.log.info('folder index not using folder listing macro')
            return True

        self.log.info('folder index replacing folder listing macro')
        tal = tal.replace(old_macro_start, new_macro_start)
        custom_folder_index.write(tal)
        return True
    def _update(self, portal):
        self.log.debug(physical_path(portal))

        t = 'folder index: <a href="%(url)s/manage_main">%(text)s</a>'
        for folder in list_folders_with_custom_index(portal):
            self.log.info(t % {
                'url': folder.absolute_url(),
                'text': physical_path(folder)
            })

        return True
    def _update(self, portal):
        t = '%(info)s folder: <a href="%(url)s/manage_main">%(text)s</a>'
        pt_start = '<metal:block metal:define-macro="page" metal:extend-macro="here/standard_template_macro">'
        old_meta_slot = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" ?/>'
        meta_slot_start = '<metal:block fill-slot="meta">'
        meta_slot = '''
<metal:block fill-slot="meta">
    <meta tal:define="description here/description;
                      content python:here.html2text(description);"
          tal:condition="content"
          tal:attributes="content content" name="description" />
    <meta tal:condition="here/keywords"
          tal:attributes="content here/keywords" name="keywords" />
    <meta tal:attributes="content here/contributor" name="author" />
    <meta tal:attributes="content here/gl_get_selected_language"
          name="dc.language" />
    <meta tal:attributes="content string:${here/title} | ${here/site_title}"
          name="title" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</metal:block>
'''

        self.log.debug(physical_path(portal))
        for folder in list_folders_with_custom_index(portal):
            tal = folder.index.read()
            if re.search(meta_slot_start, tal) is not None:
                self.log.info(t % {'info': 'already has meta slot',
                                   'url': folder.absolute_url(),
                                   'text': physical_path(folder)})
                continue

            if re.search('^' + pt_start, tal) is None and re.search(old_meta_slot, tal) is None:
                self.log.info(t % {'info': 'not using standard template macro and no old meta slot',
                                    'url': folder.absolute_url(),
                                    'text': physical_path(folder)})
                continue

            self.log.info(t % {'info': 'matched',
                               'url': folder.absolute_url(),
                               'text': physical_path(folder)})

            if re.search(old_meta_slot, tal) is not None:
                # replace only first occurance, remove the others
                tal = re.sub(old_meta_slot, meta_slot, tal, count=1)
                tal = re.sub(old_meta_slot, '', tal)
            elif re.search('^' + pt_start, tal) is not None:
                tal = re.sub(pt_start, '%s\n%s' % (pt_start, meta_slot), tal)
            folder.index.write(tal)
        return True
    def _update(self, portal):
        t = '%(info)s: <a href="%(url)s/manage_main">current skin standard template</a>'

        self.log.debug(physical_path(portal))
        standard_template = get_standard_template(portal)
        tal = standard_template.read()

        str_no_error = '<div id="breadcrumbtrail" '
        str_with_error_old = '<div id="breadcrumbtrail" on-error="here/rstk/catch_unauthorized" '
        str_with_error = '<div id="breadcrumbtrail" on-error="python:here.log_page_error(error)" '

        if str_with_error in tal:
            self.log.debug(
                '"on-error" for breadcrumb already in standard template')
            return True

        if str_no_error not in tal:
            self.log.debug('could not find breadcrumb in standard template')
            return False

        if str_with_error_old in tal:
            tal = tal.replace(str_with_error_old, str_with_error)
        else:
            tal = tal.replace(str_no_error, str_with_error)
        standard_template.write(tal)

        self.log.debug('Added "on-error" for breadcrumb in standard template')
        return True
Beispiel #11
0
    def _update(self, portal):
        self.log.debug(physical_path(portal))

        for obj in list_obsolete_comented_objects(portal):
            migrate_comments(obj, self.log)
        delete_index(portal)
        return True
    def _update(self, portal):
        t = '%(info)s: <a href="%(url)s/manage_main">current skin standard template</a>'

        self.log.debug(physical_path(portal))
        standard_template = get_standard_template(portal)
        tal = standard_template.read()

        macro_start = '<metal:block define-macro="standard-head-links">'
        macro_end = '</metal:block>'
        slot_start = '<metal:block define-slot="standard-head-links">'
        slot_end = '</metal:block>'

        if re.search(slot_start, tal) is None:
            self.log.info(t % {'info': "can't find slot",
                               'url': standard_template.absolute_url()})
            return True

        if re.search(macro_start, tal) is not None:
            return True

        pattern = '(\s*)%s((?:.|\n)*?)%s' % (slot_start, slot_end)
        replacement = '\\1%s\\1%s\\2%s\\1%s' % (slot_start, macro_start, macro_end, slot_end)
        tal = re.sub(pattern, replacement, tal)
        self.log.info(t % {'info': 'added macro',
                           'url': standard_template.absolute_url()})
        standard_template.write(tal)
        return True
    def _update(self, portal):
        count_map = {}
        object_map = {}

        def log_subobjects(parent):
            for ob_id, ob in parent.objectItems():
                class_name = ob.__class__.__name__
                count_map.setdefault(class_name, 0)
                count_map[class_name] += 1
                object_map.setdefault(class_name, [])
                if count_map[class_name] < 5 and hasattr(ob, 'absolute_url'):
                    object_map[class_name].append(ob.absolute_url())

                if hasattr(ob, 'objectItems'):
                    log_subobjects(ob)

        log_subobjects(portal)

        self.log.debug(physical_path(portal))

        for class_name, count in sorted(count_map.items()):
            self.log.debug("%s %d objects: %r" %
                           (class_name, count, object_map[class_name]))

        return True
Beispiel #14
0
    def _update(self, portal):
        t = '%(info)s: <a href="%(url)s/manage_main">current skin standard template</a>'

        self.log.debug(physical_path(portal))
        standard_template = get_standard_template(portal)
        tal = standard_template.read()

        macro_start = '<metal:block define-macro="standard-head-links">'
        macro_end = '</metal:block>'
        slot_start = '<metal:block define-slot="standard-head-links">'
        slot_end = '</metal:block>'

        if re.search(slot_start, tal) is None:
            self.log.info(t % {
                'info': "can't find slot",
                'url': standard_template.absolute_url()
            })
            return True

        if re.search(macro_start, tal) is not None:
            return True

        pattern = '(\s*)%s((?:.|\n)*?)%s' % (slot_start, slot_end)
        replacement = '\\1%s\\1%s\\2%s\\1%s' % (slot_start, macro_start,
                                                macro_end, slot_end)
        tal = re.sub(pattern, replacement, tal)
        self.log.info(t % {
            'info': 'added macro',
            'url': standard_template.absolute_url()
        })
        standard_template.write(tal)
        return True
    def _update(self, portal):
        t = '%(info)s folder: <a href="%(url)s/manage_main">%(text)s</a>'

        old_macro_start = '<metal:block use-macro="here/folder_listing/macros/content">'
        new_macro_start = '<metal:block use-macro="python:here.getFormsTool().getForm(\'folder_listing\').macros[\'listing\']">'

        self.log.debug(physical_path(portal))
        for folder in list_folders_with_custom_index(portal):
            tal = folder.index.read()
            if tal.find(new_macro_start) != -1:
                self.log.info(t % {'info': 'already uses new folder listing macro',
                                   'url': folder.absolute_url(),
                                   'text': physical_path(folder)})
                continue

            if tal.find(old_macro_start) == -1:
                self.log.info(t % {'info': 'not using folder listing macro',
                                   'url': folder.absolute_url(),
                                   'text': physical_path(folder)})
                continue

            self.log.info(t % {'info': 'replacing folder listing macro',
                               'url': folder.absolute_url(),
                               'text': physical_path(folder)})

            tal = tal.replace(old_macro_start, new_macro_start)
            folder.index.write(tal)

        custom_folder_index = portal.portal_forms._getOb('folder_index', default=None)
        if custom_folder_index is None:
            return True

        tal = custom_folder_index.read()
        if tal.find(new_macro_start) != -1:
            self.log.info('folder index already uses new folder listing macro')
            return True

        if tal.find(old_macro_start) == -1:
            self.log.info('folder index not using folder listing macro')
            return True

        self.log.info('folder index replacing folder listing macro')
        tal = tal.replace(old_macro_start, new_macro_start)
        custom_folder_index.write(tal)
        return True
    def _update(self, portal):
        t = '%(info)s folder: <a href="%(url)s/manage_main">%(text)s</a>'

        self.log.debug(physical_path(portal))
        for folder in list_folders_with_custom_index(portal):
            tal = folder.index.read()

            tal, strs = add_onerror_to_portlets_in_tal(tal)
            if strs == []:
                self.log.info(t % {'info': 'no match',
                                   'url': folder.absolute_url(),
                                   'text': physical_path(folder)})
            else:
                self.log.info(t % {'info': ','.join(strs) + ' portlet(s)',
                                   'url': folder.absolute_url(),
                                   'text': physical_path(folder)})
                folder.index.write(tal)
        return True
Beispiel #17
0
    def _update(self, portal):
        self.log.debug(physical_path(portal))

        for event in list_broken_events(portal):
            event.theme = []
            event.target_group = []
            event._p_changed = 1
            self.log.info(event.absolute_url())
        return True
Beispiel #18
0
    def _update(self, portal):
        self.log.debug(physical_path(portal))

        for event in list_broken_events(portal):
            event.theme = []
            event.target_group = []
            event._p_changed = 1
            self.log.info(event.absolute_url())
        return True
    def _update(self, portal):
        self.log.debug(physical_path(portal))
        catalog = portal.getCatalogTool()

        for brain in catalog(meta_type='Naaya Folder'):
            folder = brain.getObject()
            folder = folder.aq_base
            self.convert_publicinterface_to_custom_index(folder)
        return True
    def _update(self, portal):
        self.log.debug(physical_path(portal))
        catalog = portal.getCatalogTool()

        for brain in catalog(meta_type='Naaya Folder'):
            folder = brain.getObject()
            folder = folder.aq_base
            self.convert_publicinterface_to_custom_index(folder)
        return True
Beispiel #21
0
    def _update(self, portal):
        self.log.debug(physical_path(portal))
        objects = portal.ZopeFind(
            portal,
            obj_metatypes=['Page Template', 'Naaya Template'],
            search_sub=1)

        original1 = '<metal:block fill-slot="title">'
        original2 = '<metal:block metal:fill-slot="title">'

        target = '<metal:block metal:fill-slot="header-title">'

        t_found = 'Found duplicate title slot in: <a href="%(url)s/manage_main">%(text)s</a>'
        t_notfound = 'Not found %(text)s'

        for obj_id, obj in objects:
            tal = obj.read()

            ret = False
            if tal.find(original1) != -1:
                tal = tal.replace(original1, target)
                ret = True
            if tal.find(original2) != -1:
                tal = tal.replace(original2, target)
                ret = True

            if ret:
                self.log.info(
                    t_found % {
                        'url': '%s' % obj.absolute_url(),
                        'text': '%s:%s' % (physical_path(obj), obj.meta_type)
                    })
            else:
                self.log.info(
                    t_notfound % {
                        'url': '%s' % obj.absolute_url(),
                        'text': '%s:%s' % (physical_path(obj), obj.meta_type)
                    })

            obj.write(tal)

        return True
    def _update(self, portal):
        t = '%(info)s: <a href="%(url)s/manage_main">current skin standard template</a>'

        self.log.debug(physical_path(portal))
        standard_template = get_standard_template(portal)
        tal = standard_template.read()
        tal, strs = add_onerror_to_portlets_in_tal(tal)
        if strs:
            self.log.info(t % {'info': ','.join(strs),
                               'url': standard_template.absolute_url()})
            standard_template.write(tal)
        return True
Beispiel #23
0
    def _update(self, portal):
        t = '%(info)s: <a href="%(url)s/manage_main">current skin standard template</a>'

        self.log.debug(physical_path(portal))
        standard_template = get_standard_template(portal)
        tal = standard_template.read()

        script_channels_start = '<tal:block repeat="channel python:here.getSite().getSyndicationTool().get_script_channels()">'
        script_channels_end = '</tal:block>'
        local_channels_start = '<tal:block repeat="channel python:here.getSite().getSyndicationTool().get_local_channels()">'
        local_channels_end = '</tal:block>'

        onerror_start = '<tal:block on-error="python:here.log_page_error(error)">'
        onerror_end = '</tal:block>'

        strs = []

        if re.search(pat(script_channels_start), tal) is not None:
            if re.search(
                    '%s\s*%s' %
                (pat(script_channels_start), pat(onerror_start)), tal) is None:
                pattern = '(\s*)%s((?:.|\n)*?)%s' % (
                    pat(script_channels_start), pat(script_channels_end))
                replacement = '\\1%s\\1    %s\\2    %s\\1%s' % (
                    script_channels_start, onerror_start, onerror_end,
                    script_channels_end)
                tal = re.sub(pattern, replacement, tal)
                strs.append('changed script channels')
        else:
            strs.append("can't find script channels")

        if re.search(pat(local_channels_start), tal) is not None:
            if re.search(
                    '%s\s*%s' %
                (pat(local_channels_start), pat(onerror_start)), tal) is None:
                pattern = '(\s*)%s((?:.|\n)*?)%s' % (pat(local_channels_start),
                                                     pat(local_channels_end))
                replacement = '\\1%s\\1    %s\\2    %s\\1%s' % (
                    local_channels_start, onerror_start, onerror_end,
                    local_channels_end)
                tal = re.sub(pattern, replacement, tal)
                strs.append('changed local channels')
        else:
            strs.append("can't find local channels")

        self.log.info(t % {
            'info': ','.join(strs),
            'url': standard_template.absolute_url()
        })

        standard_template.write(tal)
        return True
    def _update(self, portal):
        t = '%(info)s: <a href="%(url)s/manage_main">current skin standard template</a>'

        self.log.debug(physical_path(portal))
        standard_template = get_standard_template(portal)
        tal = standard_template.read()
        tal, strs = add_onerror_to_portlets_in_tal(tal)
        if strs:
            self.log.info(t % {
                'info': ','.join(strs),
                'url': standard_template.absolute_url()
            })
            standard_template.write(tal)
        return True
    def _update(self, portal):
        t = '%(info)s folder: <a href="%(url)s/manage_main">%(text)s</a>'

        self.log.debug(physical_path(portal))
        for folder in list_folders_with_custom_index(portal):
            tal = folder.index.read()

            tal, strs = add_onerror_to_portlets_in_tal(tal)
            if strs == []:
                self.log.info(
                    t % {
                        'info': 'no match',
                        'url': folder.absolute_url(),
                        'text': physical_path(folder)
                    })
            else:
                self.log.info(
                    t % {
                        'info': ','.join(strs) + ' portlet(s)',
                        'url': folder.absolute_url(),
                        'text': physical_path(folder)
                    })
                folder.index.write(tal)
        return True
    def _update(self, portal):
        t = '%(info)s: <a href="%(url)s/manage_main">current skin standard template</a>'

        self.log.debug(physical_path(portal))
        standard_template = get_standard_template(portal)
        tal = standard_template.read()

        script_channels_start = '<tal:block repeat="channel python:here.getSite().getSyndicationTool().get_script_channels()">'
        script_channels_end = '</tal:block>'
        local_channels_start = '<tal:block repeat="channel python:here.getSite().getSyndicationTool().get_local_channels()">'
        local_channels_end = '</tal:block>'

        onerror_start = '<tal:block on-error="python:here.log_page_error(error)">'
        onerror_end = '</tal:block>'

        strs = []

        if re.search(pat(script_channels_start), tal) is not None:
            if re.search('%s\s*%s' % (pat(script_channels_start), pat(onerror_start)), tal) is None:
                pattern = '(\s*)%s((?:.|\n)*?)%s' % (pat(script_channels_start), pat(script_channels_end))
                replacement = '\\1%s\\1    %s\\2    %s\\1%s' % (script_channels_start, onerror_start, onerror_end, script_channels_end)
                tal = re.sub(pattern, replacement, tal)
                strs.append('changed script channels')
        else:
            strs.append("can't find script channels")

        if re.search(pat(local_channels_start), tal) is not None:
            if re.search('%s\s*%s' % (pat(local_channels_start), pat(onerror_start)), tal) is None:
                pattern = '(\s*)%s((?:.|\n)*?)%s' % (pat(local_channels_start), pat(local_channels_end))
                replacement = '\\1%s\\1    %s\\2    %s\\1%s' % (local_channels_start, onerror_start, onerror_end, local_channels_end)
                tal = re.sub(pattern, replacement, tal)
                strs.append('changed local channels')
        else:
            strs.append("can't find local channels")

        self.log.info(t % {'info': ','.join(strs),
                           'url': standard_template.absolute_url()})

        standard_template.write(tal)
        return True
    def _update(self, portal):
        count_map = {}
        object_map = {}
        def log_subobjects(parent):
            for ob_id, ob in parent.objectItems():
                class_name = ob.__class__.__name__
                count_map.setdefault(class_name, 0)
                count_map[class_name] += 1
                object_map.setdefault(class_name, [])
                if count_map[class_name] < 5 and hasattr(ob, 'absolute_url'):
                    object_map[class_name].append(ob.absolute_url())

                if hasattr(ob, 'objectItems'):
                    log_subobjects(ob)
        log_subobjects(portal)

        self.log.debug(physical_path(portal))

        for class_name, count in sorted(count_map.items()):
            self.log.debug("%s %d objects: %r" % (class_name, count, object_map[class_name]))

        return True
Beispiel #28
0
 def _update(self, portal):
     self.log.debug(physical_path(portal))
     return True
 def _update(self, portal):
     self.log.debug(physical_path(portal))
     return True