Exemplo n.º 1
0
    def getDescriptors(self, since_time):
        
        mp = self.getDeploymentPolicy().getContentOrganization().getActiveStructure().getCMFMountPoint()
        
        base_path = '/'.join(mp.getPhysicalPath())
        
        directories = self.getSkinDirectories()
        if directories is None:
            raise StopIteration            

        source_path, deploy_path = self.source_path, self.deployment_path 
        vhost_path = self.getDeploymentPolicy().getDeploymentURIs().vhost_path
            
        # get rid of trailing and leading slashes and join to base path
        source_path = extend_relative_path(clstrip('/'.join( (vhost_path, base_path, '/'.join(filter(None, source_path.split('/'))))), '/'))
        deploy_path = '/'.join(filter(None, deploy_path.split('/')))
        
        container_map = ContainerMap( directories )

        if since_time is not None:
            since_ticks = since_time.timeTime()
            
            def time_filter( dvo ):
                if isinstance( dvo, FSObject):
                    return since_ticks < dvo._file_mod_time 
                else:
                    return since_time < dvo.bobobase_modification_time()
        else:
            def time_filter( dvo ): return True                

        res = []
        for c in container_map.match( self.view_path ):
            #if not time_filter( c ):
            #    continue

            d = ContentDescriptor(c)
            d.setContentPath(deploy_path)
            d.setFileName(c.getId())
            # XXX reconsider some of this manip
            v = "%s/%s"%(source_path, c.getId())
            d.setSourcePath('/'.join(filter(None,v.split('/'))))
            d.setRenderMethod('')
            d.rule_id = self.getId()
            res.append(d)
                
        return res
Exemplo n.º 2
0
    def getDescriptors(self, since_time=None):
        """
        Get the content descriptors for the registry.

        We explicitly setup descripitors with their content
        paths since we're remapping. the default content path
        is based on physical path relative to the deployment root.

        since_time ignored
        """
        res = []

        mp = self.getDeploymentPolicy().getContentOrganization().getActiveStructure().getCMFMountPoint()
        base_path = '/'.join(mp.getPhysicalPath())

        r = self.getRegistry( self.view_path )
        content = r.getEvaluatedResources(self)
        source_path, deploy_path = self.source_path, self.deployment_path 

        uris = self.getDeploymentPolicy().getDeploymentURIs()
        vhost_path = uris.vhost_path

        # get rid of trailing and leading slashes and join to base path
        source_path = extend_relative_path(clstrip('/'.join( (vhost_path, base_path, '/'.join(filter(None, source_path.split('/'))))), '/'))
        deploy_path = '/'.join(filter(None, deploy_path.split('/')))

        # XXX the escaping seems weak.. - use a std lib func, and allow for multiple source paths.
        skin_name = self.getCurrentSkinName().replace(' ', '%20')

        for c in content:
            inline = getattr(c, "getInline", None) and c.getInline() or False
            if inline:
                continue
            d = ContentDescriptor(c)
            c.registry = r
            d.setContentPath(deploy_path)
            d.setFileName(c.getId())

            v = "%s/%s/%s"%(source_path, skin_name, c.getId())
            d.setSourcePath('/'.join(filter(None,v.split('/'))))
            d.setRenderMethod('')
            d.rule_id = self.getId()
            res.append(d)
                
        return res
Exemplo n.º 3
0
    def getDescriptors(self, since_time=None):
        """
        return the descriptor corresponding to this template resource
        
        since_time ignored
        """

        portal = self.portal_url.getPortalObject()
        view_path = self.view_path
        if view_path.startswith('/'):
            view_path = view_path[1:]
        
        ob = portal.restrictedTraverse( view_path )

        source_path, deploy_path = self.source_path, self.deployment_path 
        uris = self.getDeploymentPolicy().getDeploymentURIs()
        vhost_path = uris.vhost_path

        mp = self.getDeploymentPolicy().getContentOrganization().getActiveStructure().getCMFMountPoint()
        base_path = '/'.join(mp.getPhysicalPath())
            
        # get rid of trailing and leading slashes and join to base path
        source_path = extend_relative_path(clstrip('/'.join( (vhost_path, base_path, '/'.join(filter(None, source_path.split('/'))))), '/'))

        assert '/' in deploy_path

        idx = deploy_path.rfind('/')
        content_path = deploy_path[:idx]
        file_name = deploy_path[idx+1:]
            
        content_path = '/'.join(filter(None, content_path.split('/')))

        d = ContentDescriptor( ob )
        d.setContentPath(content_path)
        d.setFileName( file_name )
        d.setSourcePath( source_path )
        d.setRenderMethod('')        
        d.rule_id = self.getId()

        return [d]
Exemplo n.º 4
0
    def getDescriptors(self, since_time=None):
        """
        return descriptors for every unique value of a catalog index as resources

        this one utilizes the Creator catalog index.

        only field indexes can be deployed in this way.

        stores persistent data as annotation on the policy
        
        since_time not honored,
        however via comparisons to the indexes's histogram. 
        
        """
        portal = getToolByName( self, 'portal_url').getPortalObject()
        try:
            request = self.REQUEST
        except:
            log.warning("request not available, returning empty set")
            raise StopIteration
        
        view_path = self.view_path
        if view_path.startswith('/'):
            view_path = view_path[1:]

        source_path, deploy_path = self.source_path, self.deployment_path 
        uris = self.getDeploymentPolicy().getDeploymentURIs()
        vhost_path = uris.vhost_path

        mp = self.getDeploymentPolicy().getContentOrganization().getActiveStructure().getCMFMountPoint()
        base_path = '/'.join(mp.getPhysicalPath())
            
        # get rid of trailing and leading slashes and join to base path
        source_path = extend_relative_path(
                                              clstrip('/'.join(
                                                   (vhost_path, base_path, '/'.join(
                                                           filter(None,
                                                                  source_path.split('/'))))), '/')
                                              )

        for value in self.getValues( since_time ):
            if not value:
                continue
            assert '/' in deploy_path

            # initial content is portal, we change later to the bound method
            d = ContentDescriptor( portal )
            d.setContentPath(deploy_path)
            d.setFileName("%s.html"%value)
            
            v = "%s/%s"%(source_path, value)
            d.setSourcePath( normalize(v, '/')[1:] )

            # setup the values as a subpath variable to the resolved
            # view path
            renderer = request.traverse(
                d.getSourcePath()
                )
#                normalize( "%s/%s"%( self.view_path, value ),
#                           "/")[1:],
#                None
#                )

            if renderer is None:
                log.warning("invalid view for author idx %s"%(self.view_path))
                raise StopIteration

            d.content = None
            d.setRenderMethod( renderer )
            d.rule_id = self.getId()
            
            yield d