On Sat, May 28, 2011 at 5:17 PM, osimons <[email protected]> wrote:
> On May 28, 12:52 pm, Itamar O <[email protected]> wrote: > > Hi, > > In ITemplateStreamFilter#filter_stream, I need to know the realm and id > of > > the resource being processed. > > How do I obtain this information? > > The stream filter works for any output, so it may not necessarily be a > single known resource being rendered. You can try a careful lookup of > the data dict to find the context, and if found it should have a > resource attached. Something like: > > resource = data.get('context') and data['context'].resource or None > > This can of course be tweaked if you already perform conditional > checks like for template name or similar that already refine the > possible data you may see. > > Thanks Simon. This actually didn't work (I got a resource object with no attributes). I do have a condition on template (it's one of wiki-edit.html, ticket.html, admin_*.html, although I'm not sure how this helps. Either way, it seems that my functionality work even if I arbitrarily set realm = 'wiki' and id = '', so we can leave it at that. > > :::simon > > -- > 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. > > -- 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.
