Modify

Opened 3 years ago

Last modified 3 years ago

#14141 accepted enhancement

Allow wiki-Syntax in scalar.py

Reported by: anonymous Owned by: Ryan J Ollos
Priority: normal Component: WikiTableMacro
Severity: normal Keywords: patch
Cc: Ryan J Ollos Trac Release: 1.4

Description

Since r14524 it is not possible to include wiki-syntax to scalar-value output. For example, it is a nice feature to count the tickets of a user and point to the corresponding report:

{{{#!SQLScalar
SELECT '([query:?status=!closed&owner={{1}} '||count(id)||'],' FROM ticket WHERE status!="closed" AND owner="{{1}}"
}}}

The previous behaviour can be restored with the following patch:

  • (a) a/scalar.py.orig vs. (b) b/scalar.py

    diff --git a/scalar.py.orig b/scalar.py
    index 0a9657a..037147c 100644
    a b  
    99#
    1010
    1111from trac.web.chrome import add_stylesheet
    12 from trac.wiki.formatter import system_message
     12from trac.wiki.formatter import format_to_oneliner, system_message
    1313from trac.wiki.macros import WikiMacroBase
    1414from trac.util.html import html as tag
    1515from trac.util.text import exception_to_unicode
    1616from trac.util.translation import _
    1717
    18 
    1918class SQLScalar(WikiMacroBase):
    2019    """Output a number from a scalar (1x1) SQL query.
    2120
    class SQLScalar(WikiMacroBase): 
    3938        else:
    4039            value = rows[0][0] if len(rows) else "(NULL)"
    4140
    42         add_stylesheet(formatter.req, 'wikitable/css/wikitable.css')
    43         return tag.span(value, class_='wikiscalar')
     41        return format_to_oneliner(self.env, formatter.context, value)

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by figaro

Keywords: patch added

comment:2 Changed 3 years ago by Ryan J Ollos

Owner: set to Ryan J Ollos
Status: newaccepted

Modify Ticket

Change Properties
Set your email in Preferences
Action
as accepted The owner will remain Ryan J Ollos.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.