Example #1
0
    def deploy(self, context, request, section, last_triggered=None):
        """
        Deploy whole site as static content.
        """
        # get content for Anonymous users, not authenticated
        noSecurityManager()
        # assigning values
        self.context = context
        self.request = request
        self.section = section

        self._read_config(section)
        self._apply_request_modifications()

        # when last deployment took place
        modification_date = self._parse_date(last_triggered)

        ## Deploy registry files
        if self.deploy_registry_files:
            self._deploy_registry_files('portal_css', 'styles', 'styles')
            self._deploy_registry_files('portal_javascripts', 'scripts', 'scripts')
            self._deploy_registry_files('portal_kss', 'kss', 'kineticstylesheets')

        # Deploy plone_skins files (if any)
        self._deploy_skinstool_files(self.skinstool_files)
        # Deploy additional files and pages
        self._deploy_views(self.additional_files, is_page=False)
        self._deploy_views(self.additional_pages, is_page=True)

        ## Deploy Plone Site
        if self.deploy_plonesite:
            self._deploy_site(self.context)

        ## Deploy folders and pages
        catalog = getToolByName(self.context, 'portal_catalog')
        brains = catalog(meta_type=self.page_types + self.file_types,
                         modified={'query': [modification_date, ], 'range': 'min'},
                         effectiveRange = DateTime(),
                         Language = 'all',
                         )
        for brain in brains:
            if not brain.review_state or brain.review_state in self.deployable_review_states:
                obj = brain.getObject()
                # we want only objects available for anonyous users 
                if not self._available_for_anonymous(obj):
                    continue
                # check extra deployment conditions
                if not self._extra_deployment_conditions_passed(obj,
                        modification_date):
                    continue
                # check if object is a normal page
                is_page = brain.meta_type in self.page_types
                self._deploy_content(obj, is_page=is_page)

        ## find and run additional deployment steps
        self._applay_extra_deployment_steps(modification_date)
        # update last triggered date info
        settings = IStaticDeployment(self.context)
        settings.last_triggered = unicode(DateTime().strftime('%Y/%m/%d %H:%M:%S'))
    def deploy(self, context, request, section, last_triggered=None):
        """
        Deploy whole site as static content.
        """
        # get content for Anonymous users, not authenticated
        noSecurityManager()
        # assigning values
        self.context = context
        self.request = request
        self.section = section

        self._read_config(section)
        self._apply_request_modifications()

        # when last deployment took place
        modification_date = self._parse_date(last_triggered)

        ## Deploy registry files
        if self.deploy_registry_files:
            self._deploy_registry_files("portal_css", "styles", "styles")
            self._deploy_registry_files("portal_javascripts", "scripts", "scripts")
            self._deploy_registry_files("portal_kss", "kss", "kineticstylesheets")

        # Deploy plone_skins files (if any)
        self._deploy_skinstool_files(self.skinstool_files)
        # Deploy additional files and pages
        self._deploy_views(self.additional_files, is_page=False)
        self._deploy_views(self.additional_pages, is_page=True)
        self._deploy_additional_directories(self.additional_directories)

        ## Deploy Plone Site
        if self.deploy_plonesite:
            self._deploy_site(self.context)

        ## Deploy folders and pages
        catalog = getToolByName(self.context, "portal_catalog")
        brains = catalog(
            meta_type=self.page_types + self.file_types,
            modified={"query": [modification_date], "range": "min"},
            effectiveRange=DateTime(),
        )
        portal_syndication = getToolByName(self.context, "portal_syndication")
        site_parts = self.context.getPhysicalPath()
        site_path = "/".join(site_parts)
        for brain in brains:
            # check path not in excluded set
            if self.excluded_content_directories:
                brain_parts = brain.getPath().split("/")[len(site_parts) :]
                skip = False
                for path in self.excluded_content_directories:
                    path_parts = path.strip("/").split("/")
                    if path_parts == brain_parts[: len(path_parts)]:
                        skip = True
                        break
                if skip:
                    continue
            if not brain.review_state or brain.review_state in self.deployable_review_states:
                obj = brain.getObject()
                # we want only objects available for anonyous users
                if not self._available_for_anonymous(obj):
                    continue
                # check extra deployment conditions
                if not self._extra_deployment_conditions_passed(obj, modification_date):
                    continue
                # check if object is a normal page
                is_page = brain.meta_type in self.page_types
                try:
                    self._deploy_content(obj, is_page=is_page)
                    if portal_syndication.isSyndicationAllowed(obj):
                        page = "/".join(obj.getPhysicalPath()) + "/RSS"
                        page = page[len(site_path) + 1 :]
                        self._deploy_views([page], is_page=True)
                except TypeError:
                    # not a valid syndication
                    pass
                except:
                    log.error(
                        "error exporting object: %s\n%s" % ("/".join(obj.getPhysicalPath()), traceback.format_exc())
                    )

        ## find and run additional deployment steps
        self._applay_extra_deployment_steps(modification_date)
        # update last triggered date info
        settings = IStaticDeployment(self.context)
        settings.last_triggered = unicode(DateTime().strftime("%Y/%m/%d %H:%M:%S"))
    def deploy(self, context, request, section, last_triggered=None):
        """
        Deploy whole site as static content.
        """
        # get content for Anonymous users, not authenticated
        noSecurityManager()
        # assigning values
        self.context = context
        self.request = request
        self.section = section

        self._read_config(section)
        self._apply_request_modifications()

        # when last deployment took place
        modification_date = self._parse_date(last_triggered)

        ## Deploy registry files
        if self.deploy_registry_files:
            log.info('Deploying registry files: CSS, JS, KSS')
            self._deploy_registry_files('portal_css', 'styles', 'styles')
            self._deploy_registry_files('portal_javascripts', 'scripts', 'scripts')
            if getToolByName(context, 'portal_kss', None):
                self._deploy_registry_files('portal_kss', 'kss', 'kineticstylesheets')

        # Deploy plone_skins files (if any)
        log.info('Deploying files in skins folder')
        self._deploy_skinstool_files(self.skinstool_files)
        # Deploy additional files and pages
        log.info('Deploying additional files')
        self._deploy_views(self.additional_files, is_page=False)
        log.info('Deploying additional pages')
        self._deploy_views(self.additional_pages, is_page=True)

        ## Deploy Plone Site
        if self.deploy_plonesite:
            self._deploy_site(self.context)

        ## Deploy folders and pages
        catalog = getToolByName(self.context, 'portal_catalog')

        catalog_query = dict(portal_type=self.page_types + self.file_types,
                             effectiveRange=DateTime()
            )

        if modification_date is not None:
            catalog_query['modified'] = {'query': [modification_date, ],
                                         'range': 'min'}

        if self.path_filter:
            catalog_query['path'] = self.path_filter

        log.info('Querying the catalog for objects')
        brains = catalog(**catalog_query)

        log.info('Queried the catalog. Starting the process')
        portal_syndication = getToolByName(self.context, 'portal_syndication')
        site_path = '/'.join(self.context.getPhysicalPath())
        for brain in brains:
            if not brain.review_state or \
                    brain.review_state in self.deployable_review_states:
                obj = brain.getObject()
                # we want only objects available for anonyous users
                if not self._available_for_anonymous(obj):
                    continue
                # check extra deployment conditions
                if not self._extra_deployment_conditions_passed(obj,
                        modification_date):
                    continue
                # check if object is a normal page
                is_page = brain.portal_type in self.page_types
                try:
                    self._deploy_content(obj, is_page=is_page)
                    log.info('%s deployed' % brain.getPath())
                    if portal_syndication.isSyndicationAllowed(obj):
                        page = '/'.join(obj.getPhysicalPath()) + '/RSS'
                        page = page[len(site_path) + 1:]
                        self._deploy_views([page], is_page=True)
                except:
                    log.error("error exporting object: %s\n%s" % (
                        '/'.join(obj.getPhysicalPath()),
                        traceback.format_exc())
                    )

        self._apply_extra_deployment_steps(modification_date)
        # update last triggered date info
        settings = IStaticDeployment(self.context)
        settings.last_triggered = unicode(DateTime().strftime('%Y/%m/%d %H:%M:%S'))
        log.info('Static deployment completed')