Opened 3 years ago

Closed 3 years ago

#8684 closed defect (fixed)

Reported by: Owned by: dkg hasienda highest TagsPlugin normal genshi builder translation wrapper felix_schwarz, bof 0.11

I'm trying to use TagsPlugin from svn (r9419) against trac 0.11.7.

When i go to edit a wiki page, i get:

Trac detected an internal error:

TypeError: __call__() got an unexpected keyword argument 'tags_link'


The attached patch appears to resolve things for me as expected.

bugfix for #8684

Changed 3 years ago by felix_schwarz

better patch for the issue

comment:2 Changed 3 years ago by felix_schwarz

Actually while fix-tags-link.patch works around the issue, the underlying problem is that genshi.builder.tag does not provide the same interface as trac.util.translations.tag_. Therefore I copied code from Trac 0.12 to provide a compat interface.

comment:3 Changed 3 years ago by rjollos

• Description modified (diff)
• Summary changed from unexpected keyword argument 'tags_link' to [Patch] Unexpected keyword argument 'tags_link'

I'm seeing the same issue under Trac 0.11.7.

comment:4 Changed 3 years ago by bof

• Priority changed from normal to highest

Also experienced the problem, the second patch fixed it nicely.

It's surprising to have a plugin advertised as rewritten-for-0.11, to fail
in such an obvious fashion on 0.11.7. I'm upping Priority in the hope to
get the patch pushed into SVN.

comment:6 Changed 3 years ago by rjollos

I had a previous version of this plugin installed, and I'm pretty sure it was r5655. On reinstall on a new server while keeping with Trac 0.11.7, I've started experiencing this issue. I'm not sure which version of Genshi I was running previously.

Does anyone know if this issue occurred due to some recent changes on the TagsPlugin trunk, or rather if it is related to the version of Genshi being used?

Changed 3 years ago by hasienda

even better patch ;-) - just free tag_ from multiple args

comment:7 follow-up: ↓ 8 Changed 3 years ago by hasienda

• Keywords genshi builder translation wrapper added; patch removed
• Owner changed from athomas to hasienda

After I've done the i18n implementation for this plugin, I've learned some more lessons with other plugins. One of them is:

tag_ is meant as a simple replacement for tag(_( nothing more.

Consequence: If you try anything more complicated than one string with named attribute, i.e. appending more tags, this will fail. IMHO here we have such a case. The proper fix is not to do more magic around import to enhance tag_ beyond what it's not meant to be, but to move the other stuff into separate tag calls. Added bonus with attached patch:

• better PEP8 conformance (max. 79 chars/line)
• another TRANSLATOR comment in for extra clarity regarding the label text surrounding the link

I'll commit this as soon as I get positive feedback here from at least one 0.11 application.

Sorry for the inconvenience, but I've used this with Trac 0.12dev and 0.13dev without issues for ages. Would have done this much earlier, if someone had notified me before, like Ryan finally did today - thank you.

comment:8 in reply to: ↑ 7 Changed 3 years ago by rjollos

I'll commit this as soon as I get positive feedback here from at least one 0.11 application.

With 0.11.7 and the patch installed, I'm getting this error:

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/Trac-0.11.7-py2.6.egg/trac/web/main.py", line 450, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.6/site-packages/Trac-0.11.7-py2.6.egg/trac/web/main.py", line 227, in dispatch
data, content_type)
File "/usr/lib/python2.6/site-packages/Trac-0.11.7-py2.6.egg/trac/web/chrome.py", line 745, in render_template
stream |= self._filter_stream(req, method, filename, stream, data)
File "/usr/lib/python2.6/site-packages/Genshi-0.6-py2.6.egg/genshi/core.py", line 132, in __or__
return Stream(_ensure(function(self)), serializer=self.serializer)
File "/usr/lib/python2.6/site-packages/Trac-0.11.7-py2.6.egg/trac/web/chrome.py", line 848, in inner
data)
File "/usr/lib/python2.6/site-packages/TracTags-0.7dev-py2.6.egg/tractags/wiki.py", line 57, in filter_stream
return self._wiki_edit(req, stream)
File "/usr/lib/python2.6/site-packages/TracTags-0.7dev-py2.6.egg/tractags/wiki.py", line 139, in _wiki_edit
TypeError: __call__() got an unexpected keyword argument 'tags_link'


comment:9 Changed 3 years ago by hasienda

• Status changed from new to assigned

So it remains the same, bad.

As you may have noticed, I went seriously into the 0.11 maintenance business. In fact, it was a great deal of laziness before, but finally now I've setup a Trac 0.11 as well as a 0.11.7.1/0.11.8 environment for testing, and it instantly payed off: I've got a bunch of issues first-hand for the supposed new stable acct_mgr-0.3 release, that no-one else reported before, collected in "super"-ticket #8963.

After resolving this sudden strike of issues over there, I'll bring TagsPlugin into my 0.11 test environment too - much easier to come up with a solution that way.

comment:10 follow-up: ↓ 12 Changed 3 years ago by rjollos

As you suggest in 7, the replacement tag_( -> tag(_( fixes the issue. Should I just commit that fix to get this working again and then you can proceed with refactoring?

comment:11 Changed 3 years ago by hasienda

• Resolution set to fixed
• Status changed from assigned to closed

(In [10414]) TagsPlugin: (i18n) Free tag_ from multiple args, closes #8684, refs #7787.

tag_( is meant as a simple replacement for tag(_(, and nothing more.
So splitting the Genshi Element constuction into more stages resolves issues
reported for plugin applications in Trac 0.11, but add

• better PEP8 conformance (max. 79 chars/line)
• another TRANSLATOR comment regarding the label text surrounding the link

as well, if changing something here. So import of tag_ is obsolete here.

comment:12 in reply to: ↑ 10 Changed 3 years ago by hasienda

As you suggest in 7, the replacement tag_( -> tag(_( fixes the issue. Should I just commit that fix to get this working again and then you can proceed with refactoring?

I wasn't aware of the fact, that my last patch didn't include what I said in that comment. I've taken another look and not only did your 1-line patch apply indeed, moreover I found the obsolete import as stated in the commit message - so I pushed it out right away. Thank you for testing.

comment:13 Changed 3 years ago by hasienda

(In [10423]) AccountManagerPlugin: Restore 0.11 compatibility, refs #8684 and #8963.

Replace tag_ with more capable tag(_( call to prevent TypeError in
Genshi used by any Trac 0.11 release. But this is generally a good idea,
i.e. if looking at #8684.

comment:14 Changed 3 years ago by hasienda

(In [10596]) AccountManagerPlugin: Fix compatibility with Trac 0.11 once again, refs #8684 and #9092.

Replace tag_ call to prevent TypeError in Genshi used by any Trac 0.11
release.

Modify Ticket

Change Properties