On Nov 2, 1:07 am, Chris Nelson <chris.nel...@sixnet.com> wrote: > In Subtickets plugin, I find: > > def filter_stream(self, req, method, filename, stream, data): > .... > href = req.href.query(status='! > closed', > owner=ticket['owner']) > > and I want to change the link that is created. Immediately, I want it > to go to a report: > > href = somefunc("report/99?USER=%s" % > ticket['owner']) > > Ideally, the first string in there would be configurable. But I can't > find what req or req.href is or what other methods or properties it > has. Maybe this is as simple as > > href = req.href.url("/report/99/USER= > %s" % ticket['owner']) > > But I don't know if there is such a function. I've poked at Trac and > Genshi web sites and sample and Googled lots of terms and haven't > found an answer.
A very simple solution is just to use site.html and print the content of the various variables and try them out there. A streamfilter is very much an extention of the rendering context with the req and data (that gets expanded as local variables for rendering). Once upon a time I needed this (when migrating to Genshi), and I published a simple site.html example of the things I poked into to understand what is available when rendering (+ a useful template for making test calls of functions and acting on data): http://trac.edgewall.org/wiki/TracDev/PortingFromClearSilverToGenshi#Debugging The site.html is a simple way to get lots of information quickly - and hopefully it still works :-) There is also a developer plugin with various features (including details of variables). It may also be worth looking into if you want to understand more of the internals for plugin development: http://trac-hacks.org/wiki/TracDeveloperPlugin PS! For your actual href question, you want to read the source of trac.web.href.Href class, IIRC it is well documented with doctest showing how to use this link-creating utility class. >>> from trac.web.href import Href >>> href = Href('/projects') >>> print href.testing('one', two='myarg') /projects/testing/one?two=myarg Trac adds such a href (relative path to the current project) and a abs_href (for absolute urls) to req (aka Request object) with correct base paths - ready for your use. BTW. Searching the Trac source code for patterns is still the best way of getting usage examples... :::simon https://www.coderesort.com http://trac-hacks.org/wiki/osimons -- You received this message because you are subscribed to the Google Groups "Trac Development" group. To post to this group, send email to trac-...@googlegroups.com. To unsubscribe from this group, send email to trac-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/trac-dev?hl=en.