コード例 #1
0
ファイル: installer.py プロジェクト: silvacms/silva.core.conf
    def is_silva_content(self, content):
        """Is the content a Silva content ?

        You can override this method in a subclass to change this behaviour.
        """
        cls = content['instance']
        return (ISilvaObject.implementedBy(cls) or
                IVersion.implementedBy(cls))
コード例 #2
0
ファイル: installer.py プロジェクト: silvacms/silva.core.conf
    def has_default_metadata(self, content):
        """Tell if the content should have default metadata set sets.

        You can override this method in a subclass to change this behaviour.
        """
        cls = content['instance']
        return ((ISilvaObject.implementedBy(cls) and
                 not interfaces.IVersionedObject.implementedBy(cls)) or
                IVersion.implementedBy(cls))
コード例 #3
0
ファイル: installer.py プロジェクト: silvacms/silva.core.conf
    def configure_content(self, root, extension):
        """Configure extension content: metadata, addables, security.
        """
        contents = extension.get_content()

        # Configure addables
        if not self._is_installed.addables:
            addables = []
            not_addables = []
            for content in contents:
                if self.is_silva_addable(content):
                    if content['name'] not in self.not_globally_addables:
                        addables.append(content['name'])
                    else:
                        not_addables.append(content['name'])
            self.configure_addables(root, addables, not_addables)

        # Configure security
        if not self._is_installed.security:
            secured_contents = []
            for content in contents:
                if self.is_silva_content(content):
                    secured_contents.append(content['name'])
            self.configure_security(root, secured_contents)

        # Configure metadata
        if not self._is_installed.metadata:
            viewables = []
            others = []
            for content in contents:
                if self.has_default_metadata(content):
                    if (IViewableObject.implementedBy(content['instance']) or
                        IVersion.implementedBy(content['instance'])):
                        viewables.append(content['name'])
                    else:
                        others.append(content['name'])
            if viewables:
                root.service_metadata.addTypesMapping(
                    viewables,
                    ('silva-content', 'silva-extra', 'silva-settings'))
            if others:
                root.service_metadata.addTypesMapping(
                    others,
                    ('silva-content', 'silva-extra'))