def getChildDescriptors( self, descriptor, expr_context ):

        if not len( self.objectIds()  ):
            raise StopIteration

        factory = DescriptorFactory( self.getDeploymentPolicy() )
        content = descriptor.getContent()

        # if the content is not a container, we want the childo
        # descriptors to appear in the content's container.
        # to that end we set the content path on the descriptor
        organization = self.getContentOrganization()
        content_path = organization.getContentRelativePath( content )
        
        for cview in self.objectValues( ChildView.meta_type ):
            cdescriptor = factory( content )
            cview.process( cdescriptor, expr_context )

            if not descriptor.isContentFolderish():
                cdescriptor.setContentPath( content_path )
                
            source_path = normalize("%s/%s"%( descriptor.content_url,
                                              cview.source_path ),
                                    '/' )

            # setup source path for url database
            cdescriptor.setSourcePath( source_path )

            yield cdescriptor
Example #2
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