Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#4381 closed task (duplicate)

ticket.query Query cannot be used in macros

Reported by: ittayd Owned by: Jonas Borgström
Priority: normal Milestone:
Component: ticket system Version: 0.10.2
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

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

Attachments (0)

Change History (4)

comment:1 by Christian Boos, 17 years ago

Resolution: duplicate
Status: newclosed
Type: defecttask

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.

comment:2 by anonymous, 17 years ago

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.

comment:3 by Christian Boos, 17 years ago

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.

comment:4 by Christian Boos, 17 years ago

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.