Steffen Hoffmann wrote:
> Ethan Jucovy writes:
>> req is a Request object, from trac.web.api --
>> 
>> [..]
>> 
>> On Mon, Nov 1, 2010 at 8:07 PM, Chris Nelson <Chris.Nelson <at>
> 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. 
> 
> I'm searching for similar things right now. Read as Ethan advised. I
> came across trac.web.href by own research. Actually it's well
> documented in the source.
> 
> Deduced from that reading a simple
>  href = req.href.report(99, user=ticket['owner'])
> should be enough.

That creates a URL for a report link but what I'm looking for is a way
to configure a "owner URL" in trac.ini so it could be
/report/99?USER=fred, or /wiki/user/fred or
http://MyCompanyPortal.Com/somePage?USER=fred

The easiest way to do that would have been if I could put the relative
or absolute URL in trac.ini and have href do the "right thing" and not
quote/escape it.  That's what I thought
https://github.com/itota/trac-subtickets-plugin/issues#issue/13 would do
but it doesn't quite work.  What I ended up doing is having
configuration like:

  owner_url = report/24, USER:$owner

Processed with:

    owner_url = self.config.getlist('subtickets', 'owner_url')
 
    # tickets
    def _func(children, depth=0):
        ...
        for column in columns:
            if column == 'owner':
                if owner_url:
                    base = owner_url[0]
                    if len(owner_url) == 1:
                        params = None
                    else:
                        params = {}
                        for i in owner_url[1:]:
                            n, v = i.split(':')
                            if v == '$owner':
                                params[n] = ticket['owner']
                            else:
                                params[n] = v
                    href = req.href(base, params)
                else:
                    href = req.href.query(status='!closed',
                                          owner=ticket['owner'])

Which is somewhat more flexible but not perfect.

This actually is a specific case of a general problem.  We link to
*something* in an number of places that owner shows up.

 * http://trac.edgewall.org/ticket/7806 lets us link from group headers
in a report grouped by ticket owner to the report of that owner's ticket
details.
 * Subtickets provides an owner link in the child tickets list. (My
patch (incomplete above but fixed locally; I need to update that patch)
lets us click through to a URL/report we configure.
 * I've recently added SVG rendering to Estimation Tools' workload chart
and made each owner's bar a link to the owner's ticket details. (I was
going to submit a patch but the original seems to be in DOS file format
and my stuff is in Linux and the patch became unwieldy.)

What I'd really like is an owner_url option in trac.ini that worked all
over the place in Trac.  I have to get around to submiting a feature
request for that.

-- 
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