Exemplo n.º 1
0
    def remap_views(self):
        maps = self.view_maps
        views_i = {"FieldIndex": ['getLayout', 'default_page']}
        context = self.context
        catalog = self.context.portal_catalog
        setup_catalog(
            self.context,
            indexes=views_i,
            metadatas=[],
        )
        upgrades.commit(context)
        try:
            for view in maps.keys():
                brains = catalog.search({'getLayout': view})

                for brain in brains:
                    log('Changing view: %s %s->%s' %
                        (brain.getPath(), view, maps[view]))
                    try:
                        obj = brain.getObject()
                        obj.setLayout(maps[view])
                        catalog.reindexObject(obj, ['getLayout'])
                    except Exception, e:
                        log('Cant change layout: %s (%s)' %
                            (brain.getPath(), e))
                        continue
            vl = catalog.uniqueValuesFor('getLayout')
            upgrades.commit(context)
Exemplo n.º 2
0
    def remap_views(self):
        maps = self.view_maps
        views_i = {"FieldIndex": ['getLayout', 'default_page']}
        context = self.context
        catalog = self.context.portal_catalog
        setup_catalog(
            self.context,
            indexes=views_i,
            metadatas=[],
        )
        upgrades.commit(context)
        try:
            for view in maps.keys():
                brains = catalog.search({'getLayout': view})

                for brain in brains:
                    log(
                        'Changing view: %s %s->%s' % (
                            brain.getPath(),
                            view,
                            maps[view]
                        ))
                    try:
                        obj = brain.getObject()
                        obj.setLayout(maps[view])
                        catalog.reindexObject(obj, ['getLayout'])
                    except Exception, e:
                        log('Cant change layout: %s (%s)' % (
                            brain.getPath(), e))
                        continue
            vl = catalog.uniqueValuesFor('getLayout')
            upgrades.commit(context)
Exemplo n.º 3
0
                        (brain.getPath(), view, maps[view]))
                    try:
                        obj = brain.getObject()
                        obj.setLayout(maps[view])
                        catalog.reindexObject(obj, ['getLayout'])
                    except Exception, e:
                        log('Cant change layout: %s (%s)' %
                            (brain.getPath(), e))
                        continue
            vl = catalog.uniqueValuesFor('getLayout')
            upgrades.commit(context)
        finally:
            setup_catalog(
                self.context,
                indexes=[],
                metadatas=[],
                remove_indexes=views_i["FieldIndex"],
                remove_metadatas=views_i["FieldIndex"],
            )
        upgrades.commit(context)

    @onlyonce
    def postupgrade(self):
        """Mark products as correctly installed by the quickinstaller"""
        upgrades.log('postupgrade')
        context = self.context
        upgrades.quickinstall_addons(self.context,
                                     self.products, [],
                                     upgrades=self.upproducts)
        upgrades.commit(context)
Exemplo n.º 4
0
                            maps[view]
                        ))
                    try:
                        obj = brain.getObject()
                        obj.setLayout(maps[view])
                        catalog.reindexObject(obj, ['getLayout'])
                    except Exception, e:
                        log('Cant change layout: %s (%s)' % (
                            brain.getPath(), e))
                        continue
            vl = catalog.uniqueValuesFor('getLayout')
            upgrades.commit(context)
        finally:
            setup_catalog(
                self.context,
                indexes=[], metadatas=[],
                remove_indexes = views_i["FieldIndex"],
                remove_metadatas = views_i["FieldIndex"],
            )
        upgrades.commit(context)

    @onlyonce
    def postupgrade(self):
        """Mark products as correctly installed by the quickinstaller"""
        upgrades.log('postupgrade')
        context = self.context
        upgrades.quickinstall_addons(self.context, self.products, [], upgrades=self.upproducts)
        upgrades.commit(context)

    @onlyonce
    def rebuild_catalog(self):
        context = self.context