Ejemplo n.º 1
0
    def configure_kupu(self,
        linkbyuid=None,
        table_classnames=None,
        html_exclusions=None,
        style_whitelist=None,
        class_blacklist=None,
        installBeforeUnload=None, parastyles=None, refbrowser=None,
        captioning=None,
        filterSourceEdit=None,
        allowOriginalImageSize=None,
        REQUEST=None):
        """Delete resource types through the ZMI"""
        if linkbyuid is not None:
            self.linkbyuid = bool(linkbyuid)
        if table_classnames is not None:
            self.table_classnames = [t for t in table_classnames if t]
        if installBeforeUnload is not None:
            self.install_beforeunload = bool(installBeforeUnload)
        if filterSourceEdit is not None:
            self.filtersourceedit = bool(filterSourceEdit)
        if allowOriginalImageSize is not None:
            self.allowOriginalImageSize = bool(allowOriginalImageSize)

        if parastyles is not None:
            self.paragraph_styles = [ line.strip() for line in parastyles if line.strip() ]

        if html_exclusions is not None:
            newex = html_exclusions[-1]
            html_exclusions = html_exclusions[:-1]
            
            html_exclusions = [ (tuple(h.get('tags', ())), tuple(h.get('attributes', ())))
                for h in html_exclusions if h.get('keep')]

            tags = newex.get('tags', '').replace(',',' ').split()
            attr = newex.get('attributes', '').replace(',',' ').split()
            if tags or attr:
                html_exclusions.append((tuple(tags), tuple(attr)))
            self.set_html_exclusions(html_exclusions)

        if style_whitelist is not None:
            self.style_whitelist = list(style_whitelist)
        if class_blacklist is not None:
            self.class_blacklist = list(class_blacklist)

        if refbrowser is not None:
            out = StringIO()
            if refbrowser:
                self.ensureReferencesLayer(True);
            else:
                util.unregister_layers(self, ['kupu_references'], out)
            # Force compressed javascript to be recomputed.
            try:
                self.portal_javascripts.cookResources()
            except AttributeError:
                pass

        if captioning is not None:
            self.captioning = bool(captioning)

        if self.linkbyuid or self.captioning:
            util.install_transform(self)
        else:
            util.remove_transform(self)

        if REQUEST:
            REQUEST.RESPONSE.redirect(self.absolute_url() + '/kupu_config')
Ejemplo n.º 2
0
def install_transform(self, out):
    try:
        util.install_transform(self)
        util.remove_transform(self) # Transform is installed but disabled by default.
    except (NameError,AttributeError):
        print >>out, "Transform not installed."
Ejemplo n.º 3
0
def install_transform(self, out):
    try:
        util.install_transform(self)
        util.remove_transform(self) # Transform is installed but disabled by default.
    except (NameError,AttributeError):
        print >>out, "Transform not installed."