Hi

I have previously posted about this but I thought I would start a new
thread as the other is two months old now.
I am trying to make a plugin that takes the values in a custom ticket
field and turns them into links to our review board server. I have
started work on that, borrowing heavily from [1], that was pointed out
to me by Torbjörn Svensson.
However, I can't find the documentation for what exactly filter_stream
is dealing with. So far I have deleted the code that doesn't deal with
tickets, and I have changed the secondary method. However, I'm working
on the assumption that what is being returned by
    "data['ticket'][self.field_name]"
is the comma separated list of numbers that is stored in the database.
In which case, is that were I should be saving my results back to,
since it is currently being stored in field['rendered']?
So where can I find useful documentation about the data-structure of
data? Am I anywhere near the fields that I want to be using? And also,
is my plugin at the moment going to be doing what I want it to be
doing (assuming I have wiki formatting turned on for the field)?

Thanks
Scott


class InterLinksPlugin(Component):
    implements(ITemplateStreamFilter)

    field_name = 'reviewno'

    # ITemplateStreamFilter methods
    def filter_stream(self, req, method, filename, stream, data):
        # this is shamelessly stollen from MasterTickets and modified
for one field only

        # We try all at the same time to maybe catch also changed or
processed templates
        if data and filename in ["report_view.html",
"query_results.html", "ticket.html", "query.html"]:
            # For ticket.html
            if 'fields' in data and isinstance(data['fields'], list):
                for field in data['fields']:
                    if field['name'] == self.field_name and
data['ticket'][self.field_name]:
                        field['rendered'] =
self._make_link(data['ticket'][self.field_name])
        return stream

    def _make_link(self, val):
        list = []
        list.extend(re.findall(r'\d+', val))
        return string = "".join("[http://reviews.sw/r"+x+"; "+x+"] "
for str(x) in list)

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" 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-users?hl=en.

Reply via email to