Edgewall Software

Ticket #4381 (closed task: duplicate)

Opened 17 months ago

Last modified 17 months ago

ticket.query Query cannot be used in macros

Reported by: ittayd Owned by: jonas
Priority: normal Milestone:
Component: ticket system Version: 0.10.2
Severity: normal Keywords:
Cc:

Description

the object requires 'req' parameter to execute. macros have only hdf and env.

Attachments

Change History

Changed 17 months ago by cboos

  • status changed from new to closed
  • type changed from defect to task
  • resolution set to duplicate

Old-style macros are deprecated and won't be supported anymore in 0.11.

Look for "new-style" macros, i.e. plugins implementing the IWikiMacroProvider interface or even simpler, inheriting from WikiMacroBase.

See #3958.

Changed 17 months ago by anonymous

can you please elaborate? there's little information on how to do single-file plugins. i really don't want to get into the .egg and enabling plugins thing.

Changed 17 months ago by cboos

No, there's no need to build an .egg for simple plugins.

See attachment:wiki:ChristianBoos:mantis_tickets.py for an example of self-contained plugin (though this one implements IWikiSyntaxProvider, similar principle for an IWikiMacroProvider).

I'll attach a simple example here later.

Changed 17 months ago by cboos

Well, here's a very simple example of a 0.10.x macro:

from StringIO import StringIO

from trac.core import *
from trac.ticket.query import TicketQueryMacro
from trac.wiki.macros import WikiMacroBase
from trac.wiki.api import parse_args


class SearchTicketsMacro(WikiMacroBase):
    """Search for the given string in all ticket text fields"""

    def render_macro(self, formatter, name, content):
        args, kw = parse_args(content)

        buf = StringIO()
        for field in ('summary', 'keywords', 'description'):
            buf.write(TicketQueryMacro(self.env).render_macro(
                formatter, 'TicketQuery', '%s=~%s' % (field, args[0])))
        return buf.getvalue()

All what's needed is to write the above in a .py file and place that file in you environment's plugins folder.

Add/Change #4381 (ticket.query Query cannot be used in macros)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.