Modify

Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#8684 closed defect (fixed)

[Patch] Unexpected keyword argument 'tags_link'

Reported by: Daniel Kahn Gillmor Owned by: Steffen Hoffmann
Priority: highest Component: TagsPlugin
Severity: normal Keywords: genshi builder translation wrapper
Cc: Felix Schwarz, Patrick Schaaf Trac Release: 0.11

Description (last modified by Ryan J Ollos)

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 (4)

fix-tags-link.patch (642 bytes) - added by Daniel Kahn Gillmor 14 years ago.
bugfix for #8684
8684-provide-tag_-replacement.patch (1.1 KB) - added by Felix Schwarz 14 years ago.
better patch for the issue
20110705_wiki-insert_reworked.patch (1.2 KB) - added by Steffen Hoffmann 13 years ago.
even better patch ;-) - just free tag_ from multiple args
wiki-t8684-r10385.patch (680 bytes) - added by Ryan J Ollos 13 years ago.

Download all attachments as: .zip

Change History (18)

Changed 14 years ago by Daniel Kahn Gillmor

Attachment: fix-tags-link.patch added

bugfix for #8684

comment:1 Changed 14 years ago by Felix Schwarz

Cc: Felix Schwarz added; anonymous removed

Changed 14 years ago by Felix Schwarz

better patch for the issue

comment:2 Changed 14 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 14 years ago by Ryan J Ollos

Description: modified (diff)
Summary: unexpected keyword argument 'tags_link'[Patch] Unexpected keyword argument 'tags_link'

I'm seeing the same issue under Trac 0.11.7.

comment:4 Changed 14 years ago by Patrick Schaaf

Priority: normalhighest

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:5 Changed 14 years ago by anonymous

Cc: Patrick Schaaf added

comment:6 Changed 13 years ago by Ryan J Ollos

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 13 years ago by Steffen Hoffmann

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

comment:7 Changed 13 years ago by Steffen Hoffmann

Keywords: genshi builder translation wrapper added; patch removed
Owner: changed from Alec Thomas to Steffen Hoffmann

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 13 years ago by Ryan J Ollos

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'

comment:9 Changed 13 years ago by Steffen Hoffmann

Status: newassigned

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 Changed 13 years ago by Ryan J Ollos

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?

Changed 13 years ago by Ryan J Ollos

Attachment: wiki-t8684-r10385.patch added

comment:11 Changed 13 years ago by Steffen Hoffmann

Resolution: fixed
Status: assignedclosed

(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 13 years ago by Steffen Hoffmann

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.

comment:13 Changed 13 years ago by Steffen Hoffmann

(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 13 years ago by Steffen Hoffmann

(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
Set your email in Preferences
Action
as closed The owner will remain Steffen Hoffmann.
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.