Exemplo n.º 1
0
 def process(self, resource):
     if (resource.node.type not in ("content", "media") or
         resource.is_layout):
         self.logger.debug("Skipping resource: %s" % str(resource.file))
         return False
     self.logger.info("Processing %s" % resource.url)
     processor_config = self.get_node_processors(resource.node)
     processors = []
     for processer_map in processor_config:
         if resource.file.extension in processer_map:
             processors.extend(processer_map[resource.file.extension])
     resource.temp_file.parent.make()        
     resource.source_file.copy_to(resource.temp_file)  
     (original_source, resource.source_file) = (
                             resource.source_file, resource.temp_file)
     for processor_name in processors:
         processor = load_processor(processor_name)
         self.logger.debug("       Executing %s" % processor_name)
         processor.process(resource)
     
     if resource.node.type == "content":
         self.settings.CONTEXT['page'] = resource
         self.logger.debug("       Rendering Page")
         TemplateProcessor.process(resource)
         self.settings.CONTEXT['page'] = None
         
     resource.source_file = original_source
     self.logger.debug("        Processing Complete")
     return True
Exemplo n.º 2
0
 def process(self, resource):
     if (resource.node.type not in ("content", "media") or
         resource.is_layout):
         self.logger.debug("Skipping resource: %s" % str(resource.file))
         return False
     self.logger.info("Processing %s" % resource.url)
     resource.temp_file.parent.make()
     resource.source_file.copy_to(resource.temp_file)
     (original_source, resource.source_file) = (resource.source_file, resource.temp_file)
     if resource.node.type == "content" and not resource.prerendered:
         self.settings.CONTEXT['page'] = resource
         self.logger.debug("       Rendering Page")
         TemplateProcessor.process(resource)
         self.settings.CONTEXT['page'] = None
         
     resource.source_file = original_source
     self.logger.debug("        Processing Complete")
     return True
Exemplo n.º 3
0
    def process(self, resource):
        if (resource.node.type not in ("content", "media")
                or resource.is_layout):
            self.logger.debug("Skipping resource: %s" % str(resource.file))
            return False
        self.logger.info("Processing %s" % resource.url)
        resource.temp_file.parent.make()
        resource.source_file.copy_to(resource.temp_file)
        (original_source, resource.source_file) = (resource.source_file,
                                                   resource.temp_file)
        if resource.node.type == "content" and not resource.prerendered:
            self.settings.CONTEXT['page'] = resource
            self.logger.debug("       Rendering Page")
            TemplateProcessor.process(resource)
            self.settings.CONTEXT['page'] = None

        resource.source_file = original_source
        self.logger.debug("        Processing Complete")
        return True
Exemplo n.º 4
0
    def process(self, resource):
        if (resource.node.type not in ("content", "media") or
            resource.is_layout):
            self.logger.debug("Skipping resource: %s" % str(resource.file))
            return False
        self.logger.info("Processing %s" % resource.url)
        processor_config = self.get_node_processors(resource.node)
        processors = []
        for processer_map in processor_config:
            if resource.file.extension in processer_map:
                processors.extend(processer_map[resource.file.extension])
            else:
                self.logger.debug("Extension %s" % resource.file.extension)                    
                #
                # Wildcard matching: 
                # This should be the default matcher going forward
                # The above branch needs to be kept around until everyone
                # has had the chance to upgrade their settings file.
                #
                for wildcard, processor_list in processer_map.iteritems():
                    self.logger.debug(wildcard)                    
                    if fnmatch.fnmatch(resource.file.name, wildcard):
                        processors.extend(processor_list)                        
                    
        resource.temp_file.parent.make()        
        resource.source_file.copy_to(resource.temp_file)  
        (original_source, resource.source_file) = (
                               resource.source_file, resource.temp_file)
        for processor_name in processors:
            processor = load_processor(processor_name)
            self.logger.debug("       Executing %s" % processor_name)
            processor.process(resource)

        if resource.node.type == "content" and not resource.prerendered:
            self.settings.CONTEXT['page'] = resource
            self.logger.debug("       Rendering Page")
            if str(resource.file).split(".")[-1] not in EXCLUDED_EXTENSIONS:
                TemplateProcessor.process(resource)
            self.settings.CONTEXT['page'] = None
            
        resource.source_file = original_source
        self.logger.debug("        Processing Complete")
        return True
Exemplo n.º 5
0
    def process_old(self, resource):
        if (resource.node.type not in ("content", "media")
                or resource.is_layout):
            self.logger.debug("Skipping resource: %s" % str(resource.file))
            return False
        self.logger.info("Processing %s" % resource.url)
        processor_config = self.get_node_processors(resource.node)
        processors = []
        for processer_map in processor_config:
            if resource.file.extension in processer_map:
                processors.extend(processer_map[resource.file.extension])
            else:
                self.logger.debug("Extension %s" % resource.file.extension)
                #
                # Wildcard matching:
                # This should be the default matcher going forward
                # The above branch needs to be kept around until everyone
                # has had the chance to upgrade their settings file.
                #
                for wildcard, processor_list in processer_map.iteritems():
                    self.logger.debug(wildcard)
                    if fnmatch.fnmatch(resource.file.name, wildcard):
                        processors.extend(processor_list)

        resource.temp_file.parent.make()
        resource.source_file.copy_to(resource.temp_file)
        (original_source, resource.source_file) = (resource.source_file,
                                                   resource.temp_file)
        for processor_name in processors:
            processor = load_processor(processor_name)
            self.logger.debug("       Executing %s" % processor_name)
            processor.process(resource)

        if resource.node.type == "content" and not resource.prerendered:
            self.settings.CONTEXT['page'] = resource
            self.logger.debug("       Rendering Page")
            TemplateProcessor.process(resource)
            self.settings.CONTEXT['page'] = None

        resource.source_file = original_source
        self.logger.debug("        Processing Complete")
        return True