Ticket #8684 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

[Patch] Unexpected keyword argument 'tags_link'

Reported by: dkg Assigned to: hasienda
Priority: highest Component: TagsPlugin
Severity: normal Keywords: genshi builder translation wrapper
Cc: felix_schwarz, bof Trac Release: 0.11

Description (Last modified by rjollos)

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.

Attachments

fix-tags-link.patch (0.6 kB) - added by dkg on 04/08/11 00:41:06.
bugfix for #8684
8684-provide-tag_-replacement.patch (1.1 kB) - added by felix_schwarz on 04/22/11 10:11:16.
better patch for the issue
20110705_wiki-insert_reworked.patch (1.2 kB) - added by hasienda on 07/05/11 22:08:34.
even better patch ;-) - just free tag_ from multiple args
wiki-t8684-r10385.patch (0.7 kB) - added by rjollos on 07/10/11 22:30:02.

Change History

04/08/11 00:41:06 changed by dkg

  • attachment fix-tags-link.patch added.

bugfix for #8684

04/21/11 09:25:15 changed by felix_schwarz

  • cc set to felix_schwarz.

04/22/11 10:11:16 changed by felix_schwarz

  • attachment 8684-provide-tag_-replacement.patch added.

better patch for the issue

04/22/11 10:20:42 changed 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.

06/05/11 03:38:24 changed by rjollos

  • description changed.
  • 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.

06/22/11 14:59:12 changed 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.

06/23/11 09:07:20 changed by anonymous

  • cc changed from felix_schwarz to felix_schwarz, bof.

07/05/11 08:14:38 changed 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?

07/05/11 22:08:34 changed by hasienda

  • attachment 20110705_wiki-insert_reworked.patch added.

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

(follow-up: ↓ 8 ) 07/05/11 22:26:51 changed by hasienda

  • owner changed from athomas to hasienda.
  • keywords changed from patch to genshi builder translation wrapper.

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.

(in reply to: ↑ 7 ) 07/10/11 10:15:50 changed by rjollos

Replying to hasienda:

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
    insert = tag_("Tag under: (%(tags_link)s)", tags_link=link)
TypeError: __call__() got an unexpected keyword argument 'tags_link'

07/10/11 21:04:22 changed 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.

(follow-up: ↓ 12 ) 07/10/11 22:29:34 changed 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?

07/10/11 22:30:02 changed by rjollos

  • attachment wiki-t8684-r10385.patch added.

07/10/11 23:06:15 changed by hasienda

  • status changed from assigned to closed.
  • resolution set to fixed.

(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.

(in reply to: ↑ 10 ) 07/10/11 23:10:12 changed by hasienda

Replying to 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?

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.

07/10/11 23:55:14 changed 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.

08/14/11 00:42:10 changed 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.


Add/Change #8684 ([Patch] Unexpected keyword argument 'tags_link')




Change Properties
Action