Modify

Opened 7 years ago

Closed 7 years ago

#13305 closed defect (fixed)

Add support on ticket description

Reported by: anonymous Owned by: Ryan J Ollos
Priority: normal Component: MermaidMacro
Severity: normal Keywords: patch
Cc: mephistopeles84@… Trac Release:

Description

macros on wiki pages seems works well. But not working properly on ticket description.

it could be from conflict with other plugins?

Error message

Error: Processor Mermaid failed'int' object has no attribute 'replace'

mermaid contents

{{{#!Mermaid
sequenceDiagram
A->> B: Query
B->> C: Forward query
Note right of C: Thinking...
C->> B: Response
B->> A: Forward response
}}}

Environment

trac 1.0.16.dev0
tracmermaid 0.4.1 

[components]
mastertickets.api.masterticketssystem = enabled
mastertickets.web_ui.masterticketsmodule = enabled
timingandestimationplugin.* = enabled
tracjsgantt.* = enabled
tracmermaid.mermaid.mermaidmacro = enabled
tracopt.versioncontrol.svn.svn_fs.subversionconnector = enabled
tracopt.versioncontrol.svn.svn_prop.subversionmergepropertydiffrenderer = enabled
tracopt.versioncontrol.svn.svn_prop.subversionmergepropertyrenderer = enabled
tracopt.versioncontrol.svn.svn_prop.subversionpropertyrenderer = enabled
tracpygments.* = enabled
tracsubtickets.api.* = enabled
tracsubtickets.web_ui.* = enabled
tracwysiwyg.wysiwygmodule = enabled

Attachments (1)

Screen Shot 2017-10-19 at 20.13.16.png (17.1 KB) - added by Ryan J Ollos 7 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 years ago by Ryan J Ollos

I can't reproduce in an environment with just TracMermaid installed, so possibly this is a plugin conflict.

Side note: you can remove tracpygments.* = enabled and the associated plugin. Trac supports Pygments highlighting since Trac 0.11.

comment:2 Changed 7 years ago by Ryan J Ollos

Is there a traceback in the logs?

comment:3 Changed 7 years ago by Ryan J Ollos

I noticed an undefined variable description and an unused variable title. I'm not sure it's the proper fix, but based on those two findings the following patch might be needed:

  • tracmermaid/mermaid.py

     
    9393                            name = c
    9494                            break
    9595                    else:
    96                         name = description
     96                        name = title
    9797                    line = line[0:m.start(1)] + '"%s" "%s"' % (
    9898                        href.replace('"', ''), name.replace('"', ''))
    9999            lines.append(line)

comment:4 Changed 7 years ago by figaro

Keywords: patch added

comment:5 in reply to:  2 Changed 7 years ago by anonymous

Replying to Ryan J Ollos:

Is there a traceback in the logs?

Hi, this is who made this ticket. thank you for giving attention to this issue.

btw, traceback below is made after applying patch you mentioned.(name = descriptiontitle) and tracpygments.* = enable in trac.ini also commented.

I'm going to look for which plugin in my environment making conflict with mermaidmacro.

2017-10-17 09:23:11,970 Trac[mermaid] DEBUG: content sequenceDiagram

A->> B: Query

B->> C: Forward query

Note right of C: Thinking...

C->> B: Response

B->> A: Forward response


2017-10-17 09:23:11,971 Trac[formatter] ERROR: Processor Mermaid failed for <Resource u'ticket:418'>:
Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 1191, in _exec_processor
    return processor.process(text)
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 364, in process
    text = self.processor(text)
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 348, in _macro_processor
    text, self.args)
  File "build\bdist.win32\egg\tracmermaid\mermaid.py", line 68, in expand_macro
    escape(context.resource.id),
  File "c:\users\mcsrem~1\appdata\local\temp\easy_install-gq73fi\Genshi-0.7-py2.7-win32.egg.tmp\genshi\core.py", line 519, in escape
    text = text.replace('&', '&amp;') \
AttributeError: 'int' object has no attribute 'replace'

comment:6 Changed 7 years ago by Ryan J Ollos

Ah, this is looking familiar. Which version of Genshi and is it compiled with speedups or not? You can find the information on the /about page.

comment:7 Changed 7 years ago by anonymous

Hi, this is also who made this ticket.

I made very ugly patch in code and it works. Thank you for assistance.

            </script>""" % (
                id_attr,
                escape(context.resource.realm),
---                escape(context.resource.id),

+++                escape(str(context.resource.id) if isinstance(context.resource.id, int) else context.resource.id),
                escape(context.resource.version or ''),
                escape(unicode_quote(content)),
                escape(content))

it seems be escape method from genshi only works properly with string type argument. and context.resource.id is supposed to be string type but some of old plugin in my environment changed to int type.

If there are some kind of agreement about type of property from resource object, I should blame some of old plugins which still don't know which one. Or blame myself because I didn't check upward compatibility of every plugins from 0.12 to 1.0.

comment:8 Changed 7 years ago by Ryan J Ollos

IIRC, issue is only seen with certain Genshi versions/configurations. Could you please let me know your Genshi version and with or without speedups so that I can reproduce?

comment:9 in reply to:  8 Changed 7 years ago by anonymous

Replying to Ryan J Ollos:

IIRC, issue is only seen with certain Genshi versions/configurations. Could you please let me know your Genshi version and with or without speedups so that I can reproduce?

it's Genshi-0.7-py2.7-win32.

Changed 7 years ago by Ryan J Ollos

comment:10 Changed 7 years ago by Ryan J Ollos

Issue only occurs from Genshi without speedups.

comment:11 Changed 7 years ago by Ryan J Ollos

In 16902:

TracMermaid 0.4.1: Fix undefined variable

Require Trac >= 1.0.

Refs #13305.

comment:12 Changed 7 years ago by Ryan J Ollos

Owner: changed from tkob-trac to Ryan J Ollos
Status: newaccepted

comment:13 Changed 7 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 16903:

TracMermaid 0.4.2: Fix AttributeError when resource.id not string

Fixes #13305.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
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.