Logo Search packages:      
Sourcecode: zope-cpsskins version File versions  Download package

def CPSSkins::PortalTheme::PortalTheme::rebuild (   self,
  kw 
)

Rebuild the theme

Definition at line 951 of file PortalTheme.py.

00951                            :
        """
        Rebuild the theme
        """

        mtool = getToolByName(self, 'portal_membership')

        # set permissions
        setperms = kw.get('setperms', 0)
        canonizeId(self)
        if setperms:
            verifyThemePerms(self)

        # Check the presence of pages
        pages = self.getPages()
        if len(pages) == 0 and mtool.checkPermission(ManageThemes, self):
            o = aq_base(self)
            # create a default page
            page = self.addThemePage(
                title='Default Page',
                color=getattr(o, 'color', ''),
                shape=getattr(o, 'shape', ''),
                align=getattr(o, 'align', 'center'),
                renderer=getattr(o, 'theme_renderer', 'default'))
            # move the page blocks to the page
            for pageblock in self.objectValues('Page Block'):
                cookie = self.manage_cutObjects(pageblock.getId())
                page.manage_pasteObjects(cookie)

        # check the presence of theme folders
        themefolders = self.cpsskins_listImageCategories()
        themefolders.extend(['styles', 'palettes'])

        for themefolder in themefolders:
            backupid = themefolder + '-bak'
            objs = self.objectIds()
            if backupid in objs:
                self.manage_delObjects([backupid])

            if themefolder not in objs:
                try:
                    self.invokeFactory('Theme Folder', id=themefolder)
                except Unauthorized:
                    pass
                continue

            else:
                folder = getattr(self.aq_inner.aq_explicit, themefolder)
                if getattr(aq_base(folder), 'isthemefolder', 0):
                    continue

                self.manage_renameObjects([themefolder], [backupid])
                backup_folder = getattr(self.aq_inner.aq_explicit, backupid)
                objects = backup_folder.objectIds()
                cookie = backup_folder.manage_cutObjects(objects)
                self.invokeFactory('Theme Folder', themefolder)
                new_folder = getattr(self.aq_inner.aq_explicit, themefolder, None)
                if new_folder is not None:
                    new_folder.manage_pasteObjects(cookie)
                    self.manage_delObjects([backupid])

        # move disallowed objects to lost+found
        for (id, o) in self.objectItems():
            if getattr(aq_base(o), 'isportalthemepage', 0):
                continue
            if getattr(aq_base(o), 'isthemefolder', 0):
                continue
            # XXX page blocks are still allowed but must be moved
            if getattr(aq_base(o), 'isportalpageblock', 0):
                continue
            moveToLostAndFound(self, o)

        for obj in self.getPages():
            obj.rebuild(**kw)

        for obj in self.findStyles():
            obj.rebuild(**kw)

        # Styles
        styles_dir = self.getStylesFolder()
        for (id, obj) in styles_dir.objectItems():
            if isBroken(aq_base(obj)):
                styles_dir.manage_delObjects(id)
                continue
            if getattr(aq_base(obj), 'isportalstyle', 0):
                continue
            moveToLostAndFound(self, obj)

        # Palettes
        palettes_dir = self.getPalettesFolder()
        for (id, obj) in palettes_dir.objectItems():
            if isBroken(aq_base(obj)):
                palettes_dir.manage_delObjects(id)
                continue
            if getattr(aq_base(obj), 'isportalpalette', 0):
                continue
            moveToLostAndFound(self, obj)

        ids = self.objectIds()
        for themefolder in themefolders:
            if themefolder not in ids:
                continue
            obj = getattr(self, themefolder, None)
            if obj is not None and setperms:
                verifyThemePerms(obj)

        # rebuild the theme properties
        rebuild_properties(self)

        # invalidate the cache
        self.clearCache()

    #
    # Local methods


Generated by  Doxygen 1.6.0   Back to index