It is, but not the bug you think it is. Most likely that a blob of rendered
wiki text. A long standing issue is that the wiki renderer outputs a string,
and not a genshi event stream (since it predates Genshi).

--Noah

> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of carsten.klein
> Sent: Wednesday, January 20, 2010 10:55 AM
> To: Trac Development
> Subject: [Trac-dev] Re: Having trouble with Genshi Templates and
> ITemplateStreamFilter interface
> 
> 
> Well, after getting myself up, lazy as I am, I realized by tracing the
> transformation, that the template filter is applied before the stream
> is actually rendered, i.e. the content of the wiki page is still not
> part of the generated
> template:
> 
> (None, ('TEXT', <Markup ...
> 
> so any match on the content of the page, that is not part of the
> template, will actually fail.
> 
> I presume this to be a bug in trac, what do you think?
> 
> Regards
> 
> Carsten
> 
> 
> On 19 Jan., 23:44, "carsten.klein" <[email protected]>
> wrote:
> > Hello All,
> >
> > the problem is so, that the internally used Transformer from Genshi
> > fails to match certain content either from the site.html template or
> > from a minimal plugin implementing the ITemplateStreamFilter
> > interface.
> >
> > Here is a snippet of code from the template:
> >
> > (1)        <div py:match="a[ @class='ext-link' ]/span [ @class='icon'
> > ]" py:strip=""/>
> >
> > This fails to match and thus remove the span that is part of every
> > external link.
> >
> > Here are some other examples that will actually work
> >
> > (2)        <div py:match="p[ @class='path noprint' ]/a [
> > @class='pathentry first' ]" py:strip=""/>
> > (3)       <div py:match="div[ @class='trac-modifiedby' ]"
> py:strip=""/
> >
> >
> >
> > Any tips why (1) does not work and (2) and (3) will work?
> >
> > And now to the problem with the minimal plugin used for rewriting the
> > external links on the server side:
> >
> > from genshi.filters import Transformer from trac.core import
> > Component, implements from trac.web.api import ITemplateStreamFilter
> >
> > class RewriteExternalLinksPlugin( Component ):
> >
> >         implements( ITemplateStreamFilter )
> >
> >         # ITemplateStreamFilter methods
> >
> >         def filter_stream( self, req, method, filename, stream, data
> > ):
> >
> >                 filter = Transformer( 'descendant-or-self::a [
> > @class="ext-link" ]' )
> >                 # FIXME does not match ext-links inside #content
> >                 return stream | filter.attr( 'target', '_blank' )
> >
> > What it does is, that it will replace all external links placed in
> the
> > site.html template manually, e.g. links to external sites not part of
> > the wiki page. These external links will then open in a new browser
> > window as one could expect from the above transformation.
> >
> > What it does not, is that all external links inside #content will not
> > be modified. It will simply ignore these, regardless of how I define
> > the xpath in the above selection.
> >
> > Versions:
> > Trac-0.12dev_r0-py2.6
> > Genshi-0.6dev_r0-py2.6
> > Python 2.6
> >
> > TIA for your interest and help.
> >
> > Regards
> >
> > Carsten

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en.


Reply via email to