Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#14042 closed defect (fixed)

TracTicketReferencePlugin does not work with Trac 1.4

Reported by: Eric Berquist Owned by: Tetsuya Morimoto
Priority: normal Component: TracTicketReferencePlugin
Severity: normal Keywords:
Cc: Trac Release: 1.4


I'm seeing this in trac.log:

2021-08-07 20:36:55,201 Trac[chrome] ERROR: Jinja2 TypeError error while rendering XML/HTML template
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/trac/web/", line 1706, in _iterable_jinja_content
    for chunk in stream:
  File "/usr/local/lib/python2.7/dist-packages/jinja2/", line 1357, in __next__
    return self._next()
  File "/usr/local/lib/python2.7/dist-packages/jinja2/", line 1334, in _buffered_generator
    c = next(self._gen)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/", line 1125, in generate
    yield self.environment.handle_exception()
  File "/usr/local/lib/python2.7/dist-packages/jinja2/", line 832, in handle_exception
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/templates/ticket.html", line 12, in top-level template code
    # extends 'layout.html'
  File "/usr/local/lib/python2.7/dist-packages/trac/templates/layout.html", line 12, in top-level template code
    # import "macros.html" as jmacros with context
  File "/usr/local/lib/python2.7/dist-packages/trac/templates/theme.html", line 16, in top-level template code
    # block head
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/templates/ticket.html", line 30, in block "head"
    ${ super() }
  File "/usr/local/lib/python2.7/dist-packages/trac/templates/layout.html", line 61, in block "head"
    var ${key}=${to_json(value)|safe};
  File "/usr/local/lib/python2.7/dist-packages/trac/util/", line 479, in to_json
    text = TracJSONEncoder(sort_keys=True, separators=(',', ':')).encode(value)
  File "/usr/lib/python2.7/json/", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib/python2.7/json/", line 431, in _iterencode
    for chunk in _iterencode_list(o, _current_indent_level):
  File "/usr/lib/python2.7/json/", line 332, in _iterencode_list
    for chunk in chunks:
  File "/usr/lib/python2.7/json/", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python2.7/json/", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python2.7/json/", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python2.7/json/", line 442, in _iterencode
    o = _default(o)
  File "/usr/local/lib/python2.7/dist-packages/trac/util/", line 473, in default
    return JSONEncoder.default(self, o)
  File "/usr/lib/python2.7/json/", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <Fragment> is not JSON serializable

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by Jun Omae

The plugin currently doesn't support Trac 1.4.

Could you please try the following patch and let us know the results?

  • ticketref/

    2626    # IEnvironmentSetupParticipant methods
    2727    def environment_created(self):
    28         self.upgrade_environment(self.env.get_db_cnx())
     28        self.upgrade_environment()
    30     def environment_needs_upgrade(self, db):
     30    def environment_needs_upgrade(self, db=None):
    3131        for field in CUSTOM_FIELDS:
    3232            if field["name"] not in self.config["ticket-custom"]:
    3333                return True
    3434        return False
    36     def upgrade_environment(self, db):
     36    def upgrade_environment(self, db=None):
     37        save = False
    3738        custom = self.config["ticket-custom"]
    3839        for field in CUSTOM_FIELDS:
    3940            if field["name"] not in custom:
    4041                custom.set(field["name"], field["type"])
    4142                for key, value in field["properties"]:
    4243                    custom.set(key, value)
     44                    save = True
     45        if save:
    4548    def has_ticket_refs(self, ticket):
    4649        refs = ticket[TICKETREF]
  • ticketref/

    11# -*- coding: utf-8 -*-
    22from pkg_resources import resource_filename
    4 from genshi.builder import tag
    54from trac.core import Component, implements
    65from trac.web.api import IRequestFilter, ITemplateStreamFilter
    76from import ITemplateProvider, add_script, add_stylesheet
    87from trac.resource import ResourceNotFound
    98from trac.ticket.model import Ticket
     9from trac.util.html import tag
    1010from trac.util.text import shorten_line
    1111from trac.util.translation import domain_functions

comment:2 Changed 3 years ago by Eric Berquist

Yes, this works!

comment:3 Changed 3 years ago by Jun Omae

Resolution: fixed
Status: newclosed

In 18442:

TracTicketReferencePlugin: make compatible with Trac 1.4 (closes #14042)

comment:4 Changed 3 years ago by Jun Omae

Thanks for the feedback!

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Tetsuya Morimoto.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

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

Note: See TracTickets for help on using tickets.