On 11 Feb., 18:30, Erik Bray <[email protected]> wrote:
> On Tue, Feb 10, 2009 at 1:19 PM, watho <[email protected]> wrote:
>
> > Hello,
>
> > i try to add the progressmeter-box from the ProgressMeter-Macro
> > (https://trac-hacks.org/wiki/ProgressMeterMacro) using
> > ITemplateStreamFilter.filter_stream().
>
> > The code:
> > ticket_box = tag.fieldset(id='tickets')(tag.legend(u'Ticketstatus'),
> > format_to_html(self.env, Context.from_request(req), "[[ProgressMeter
> > (owner=$USER)]]" ))
> > stream = stream|Transformer('//fields...@id="properties"]').after
> > (ticket_box)
>
> > works and produces the desired output. However it seems to result in
> > an endless loop, which is aborted with an RuntimeError: maximum
> > recursion depth exceeded. (full stacktrace below)
>
> > How can i avoid this? Or is there a better way to do this?
>
> Hard to be sure without seeing your full code, but make sure that your
> ITemplateStreamFilter is *only* applying to one specific template (I'm
> guessing ticket.html from the looks of it) and not to any other.

It seems your are right. I have to apply the filter-method only on one
template. The following minimal example produces the error:

class WikiSystemsInterface(Component):
    implements(ITemplateStreamFilter)
    # ITemplateStreamFilter methods
    def filter_stream(self, req, method, filename, stream, data):
        if not (filename == 'wiki_view.html' or 'wiki_edit.html'):
            return stream
        req_path = req.path_info
        if req_path.startswith(r'/wiki/mitarbeiter'):
            ticket_list = tag.fieldset(id='tickets')(tag.legend
(u'Ticketstatus'), format_to_html(self.env, Context.from_request(req),
"[[ProgressMeter(owner=$User)]]"))
            stream = stream|Transformer('//d...@id="content"]').prepend
(ticket_list)
        return stream

However changing
  if not (filename == 'wiki_view.html' or 'wiki_edit.html'):
to
  if not (filename == 'wiki_view.html'):
works and now i'm using two different ITemplateStreamFilter.

Thanks for your help.

MfG WaTho
--~--~---------~--~----~------------~-------~--~----~
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