def _configureComposables(self, node):
     """ Configure the mapping between content types and layouts
     """
     wtool = toolWrapper(self.context)
     comp_items = list()
     # Register composables first
     for composable in _filterNodes(node.childNodes):
         comp_items.append(composable.getAttribute('name'))
     wtool.registerAsComposable(comp_items)
     for composable in _filterNodes(node.childNodes):
         composable_id = composable.getAttribute('name')
         default_viewlet = ''
         c_viewlets = list()
         # Now register viewlets for each composable
         for c_viewlet in _filterNodes(composable.childNodes):
             c_viewlet_id = c_viewlet.getAttribute('name')
             c_viewlets.append(c_viewlet_id)
             if c_viewlet.hasAttribute('default'):
                 default_viewlet = c_viewlet_id
         if default_viewlet == '':
             if c_viewlets == []:
                 raise ValueError
             default_viewlet = c_viewlets[0]
         wtool.setViewletsForType(composable_id, c_viewlets,
                                  default_viewlet)
         self._logger.info(
             'Composable: "%s" registered with viewlets: "%s"' %
             (composable_id, ' '.join(c_viewlets)))
         self._logger.info('Default layout for "%s" is set to: "%s"' %
                           (composable_id, default_viewlet))
    def _configureLayouts(self, node):
        """ Configure the layouts
        """
        wtool = toolWrapper(self.context)

        # Make sure the layouts folder exists.
        if not shasattr(self.context, LAYOUTS):
            from Products.CompositePack.viewlet import container
            container.addLayoutContainer(
                self.context,
                id=LAYOUTS,
                title='A Container for registered Layouts')
        # Register the layouts
        for layout in _filterNodes(node.childNodes):
            layout_id = layout.getAttribute('name')
            layout_title = layout.getAttribute('title')
            layout_skin_method = layout.getAttribute('skin_method')
            wtool.registerLayout(layout_id.encode(), layout_title.encode(),
                                 layout_skin_method.encode())
            self._logger.info('Layout: "%s" registered' %
                              layout_title.encode())
            if layout.hasAttribute('default'):
                wtool.setDefaultLayout(layout_id)
                self._logger.info('Layout: "%s" set as tool default layout' %
                                  layout_title.encode())
    def _configureComposites(self, node):
        """
        Configure the mapping between content types and layouts
        """
        wtool = toolWrapper(self.context)
        comp_items = list()
        # Register composites first
        for composite in _filterNodes(node.childNodes):
            comp_items.append(composite.getAttribute('name'))
        wtool.registerAsComposite(comp_items)
        for composite in _filterNodes(node.childNodes):
            composite_id = composite.getAttribute('name')
            default_id = ''
            c_layouts = list()
            # Now register layouts for each composable
            for c_layout in _filterNodes(composite.childNodes):
                c_layout_id = c_layout.getAttribute('name')
                c_layouts.append(c_layout_id)
                if c_layout.hasAttribute('default'):
                    default_id = c_layout_id

            if default_id == '':
                if c_layouts == []:
                    raise ValueError
                default_id = c_layouts[0]

            for c_layout in c_layouts:
                layout = wtool.getLayoutById(c_layout)
                wtool.registerLayoutForType(layout, composite_id)

            default_layout = wtool.getLayoutById(default_id)
            wtool.setDefaultLayoutForType(default_layout, composite_id)
            self._logger.info('Composite: "%s" registered with layouts: "%s"' % (composite_id,' '.join(c_layouts)))
            self._logger.info('Default layout for "%s" is set to: ""%s"' % (composite_id, default_id))
 def _configureComposables(self, node):
     """ Configure the mapping between content types and layouts
     """
     wtool = toolWrapper(self.context)
     comp_items = list()
     # Register composables first
     for composable in _filterNodes(node.childNodes):
         comp_items.append(composable.getAttribute('name'))
     wtool.registerAsComposable(comp_items)
     for composable in _filterNodes(node.childNodes):
         composable_id = composable.getAttribute('name')
         default_viewlet = ''
         c_viewlets = list()
         # Now register viewlets for each composable
         for c_viewlet in _filterNodes(composable.childNodes):
             c_viewlet_id = c_viewlet.getAttribute('name')
             c_viewlets.append(c_viewlet_id)
             if c_viewlet.hasAttribute('default'):
                 default_viewlet = c_viewlet_id
         if default_viewlet == '':
             if c_viewlets == []:
                 raise ValueError
             default_viewlet = c_viewlets[0]
         wtool.setViewletsForType(composable_id, c_viewlets, default_viewlet)
         self._logger.info('Composable: "%s" registered with viewlets: "%s"' % (composable_id,' '.join(c_viewlets)))
         self._logger.info('Default layout for "%s" is set to: "%s"' % (composable_id, default_viewlet))
    def _configureViewlets(self, node):
        """ Configure the Viewlets
        """
        wtool = toolWrapper(self.context)

        # Make sure the viewlets folder exists.
        if not shasattr(self.context, VIEWLETS):
            from Products.CompositePack.viewlet import container
            container.addViewletContainer(self.context, id=VIEWLETS,
                                 title='A Container for registered Viewlets')
        # Register the viewlets
        for viewlet in _filterNodes(node.childNodes):
            viewlet_id = viewlet.getAttribute('name')
            viewlet_title = viewlet.getAttribute('title')
            viewlet_skin_method = viewlet.getAttribute('skin_method')
            wtool.registerViewlet(viewlet_id.encode(), viewlet_title.encode(), viewlet_skin_method.encode())
            self._logger.info('Viewlet: "%s" registered' % viewlet_title.encode())
    def _configureLayouts(self, node):
        """ Configure the layouts
        """
        wtool = toolWrapper(self.context)

        # Make sure the layouts folder exists.
        if not shasattr(self.context, LAYOUTS):
            from Products.CompositePack.viewlet import container
            container.addLayoutContainer(self.context, id=LAYOUTS,
                                  title='A Container for registered Layouts')
        # Register the layouts
        for layout in _filterNodes(node.childNodes):
            layout_id = layout.getAttribute('name')
            layout_title = layout.getAttribute('title')
            layout_skin_method = layout.getAttribute('skin_method')
            wtool.registerLayout(layout_id.encode(), layout_title.encode(), layout_skin_method.encode())
            self._logger.info('Layout: "%s" registered' % layout_title.encode())
            if layout.hasAttribute('default'):
                wtool.setDefaultLayout(layout_id)
                self._logger.info('Layout: "%s" set as tool default layout' % layout_title.encode())
    def _configureViewlets(self, node):
        """ Configure the Viewlets
        """
        wtool = toolWrapper(self.context)

        # Make sure the viewlets folder exists.
        if not shasattr(self.context, VIEWLETS):
            from Products.CompositePack.viewlet import container
            container.addViewletContainer(
                self.context,
                id=VIEWLETS,
                title='A Container for registered Viewlets')
        # Register the viewlets
        for viewlet in _filterNodes(node.childNodes):
            viewlet_id = viewlet.getAttribute('name')
            viewlet_title = viewlet.getAttribute('title')
            viewlet_skin_method = viewlet.getAttribute('skin_method')
            wtool.registerViewlet(viewlet_id.encode(), viewlet_title.encode(),
                                  viewlet_skin_method.encode())
            self._logger.info('Viewlet: "%s" registered' %
                              viewlet_title.encode())
    def _configureComposites(self, node):
        """
        Configure the mapping between content types and layouts
        """
        wtool = toolWrapper(self.context)
        comp_items = list()
        # Register composites first
        for composite in _filterNodes(node.childNodes):
            comp_items.append(composite.getAttribute('name'))
        wtool.registerAsComposite(comp_items)
        for composite in _filterNodes(node.childNodes):
            composite_id = composite.getAttribute('name')
            default_id = ''
            c_layouts = list()
            # Now register layouts for each composable
            for c_layout in _filterNodes(composite.childNodes):
                c_layout_id = c_layout.getAttribute('name')
                c_layouts.append(c_layout_id)
                if c_layout.hasAttribute('default'):
                    default_id = c_layout_id

            if default_id == '':
                if c_layouts == []:
                    raise ValueError
                default_id = c_layouts[0]

            for c_layout in c_layouts:
                layout = wtool.getLayoutById(c_layout)
                wtool.registerLayoutForType(layout, composite_id)

            default_layout = wtool.getLayoutById(default_id)
            wtool.setDefaultLayoutForType(default_layout, composite_id)
            self._logger.info('Composite: "%s" registered with layouts: "%s"' %
                              (composite_id, ' '.join(c_layouts)))
            self._logger.info('Default layout for "%s" is set to: ""%s"' %
                              (composite_id, default_id))