Modify

Opened 6 months ago

Closed 3 months ago

Last modified 3 months ago

#13033 closed defect (fixed)

TypeError: pages() takes exactly 2 arguments (1 given)

Reported by: Massimo Owned by: Ryan J Ollos
Priority: normal Component: FieldTooltipPlugin
Severity: blocker Keywords:
Cc: Trac Release: 1.2

Description

Since update to Trac 1.2 I get the following error with the latest revision of FieldToolTip:

 Trac detected an internal error:

TypeError: pages() takes exactly 2 arguments (1 given)
2017-01-09 09:16:57,747 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/ticket/271'">, referrer 'http://project-pq/trac-pqp/ticket/271'
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/trac/web/main.py", line 613, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib64/python2.7/site-packages/trac/web/main.py", line 273, in dispatch
    iterable=chrome.use_chunked_encoding)
  File "/usr/lib64/python2.7/site-packages/trac/web/chrome.py", line 1159, in render_template
    encoding='utf-8')
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 184, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/lib64/python2.7/site-packages/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "/usr/lib64/python2.7/site-packages/genshi/output.py", line 350, in __call__
    for kind, data, pos in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/output.py", line 829, in __call__
    for kind, data, pos in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/output.py", line 669, in __call__
    for kind, data, pos in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/output.py", line 774, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/lib64/python2.7/site-packages/genshi/output.py", line 594, in __call__
    for ev in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/trac/web/chrome.py", line 1426, in _strip_accesskeys
    for kind, data, pos in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/trac/web/chrome.py", line 1415, in _generate
    for kind, data, pos in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 706, in _unmark
    for mark, event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 1168, in __call__
    for mark, event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 746, in __call__
    mark, subevent = next()
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 702, in _mark
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 706, in _unmark
    for mark, event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 1076, in __call__
    for mark, event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 118, in __iter__
    event = self.stream.next()
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 734, in __call__
    for mark, event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/filters/transform.py", line 702, in _mark
    for event in stream:
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/fieldtooltip/fieldtooltip.py", line 194, in __call__
    data = self._add_title(data, 'th', 'id', 'h_', after_stream, depth)
  File "build/bdist.linux-x86_64/egg/fieldtooltip/fieldtooltip.py", line 227, in _add_title
    text = self.parent.pages.get(attr_value_locale,
  File "/usr/lib64/python2.7/site-packages/trac/cache.py", line 73, in __get__
    return CacheManager(instance.env).get(id, self.retriever, instance)
  File "/usr/lib64/python2.7/site-packages/trac/cache.py", line 242, in get
    data = retriever(instance)
TypeError: pages() takes exactly 2 arguments (1 given)

Attachments (1)

t13033.patch (11.8 KB) - added by Ryan J Ollos 4 months ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 6 months ago by Ryan J Ollos

You'll probably need to remove the db argument from pages. For backward compatibility you could try using db=None and removing the optional db argument from WikiPage: fieldtooltipplugin/0.12/fieldtooltip/fieldtooltip.py@14215:99,101#L94.

Untested patch:

  • 0.12/fieldtooltip/fieldtooltip.py

     
    9292        pass
    9393
    9494    @cached
    95     def pages(self, db):
     95    def pages(self, db=None):
    9696        # retrieve wiki contents for field help
    9797        pages = {}
    9898        prefix_len = len(FieldTooltip._wiki_prefix)
    9999        wiki_pages = WikiSystem(self.env).get_pages(FieldTooltip._wiki_prefix)
    100100        for page in wiki_pages:
    101             text = WikiPage(self.env, page, db=db).text
     101            text = WikiPage(self.env, page).text
    102102            pages[page[prefix_len:]] = text[0:text.find('----')]
    103103        return pages
    104104

Or you could just make a new branch for Trac 1.2 and drop both db arguments.

comment:2 Changed 5 months ago by Massimo

I tried that patch. /newticket loads without error now, but tooltips are not working.

Changed 4 months ago by Ryan J Ollos

Attachment: t13033.patch added

comment:3 Changed 4 months ago by Ryan J Ollos

Please try t13033.patch.

comment:4 Changed 4 months ago by Ryan J Ollos

The patch could probably be made backward-compatible with Trac 0.12 by using def pages(self, db=None): and testing the arity of WikiPage.__init__ before deciding whether to pass the db argument. Let me know if you'd like me to rework the patch to incorporate those changes.

comment:5 Changed 3 months ago by Ryan J Ollos

Owner: changed from Matoba Akihiro to Ryan J Ollos
Status: newaccepted

Okay, I tested with 0.12, 1.0 and 1.2. I will commit, which I hope is okay.

comment:6 Changed 3 months ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 16405:

FieldTooltip 0.7: Make compatible with Trac 1.2

The plugin is still compatible with Trac 0.12 and 1.0.

Fixes #13033.

comment:7 Changed 3 months ago by Massimo

Resolution: fixed
Status: closedreopened

I have built r16405, but I can't see any Tooltips eventhough I still have the old wikis for the tooltips.

The only tooltip is on the Cc input field but this looks different from the FieldTooltipPlugin. Where is this one defined?

comment:8 Changed 3 months ago by Massimo

According to /about it is loaded:

FieldTooltip 	0.7 	/mnt/data/trac/projects/trac-ppp/plugins/FieldTooltip-0.7-py2.7.egg

I don't see an error in the log.

comment:9 Changed 3 months ago by Ryan J Ollos

Do a hard refresh of the page and then check the browser console.

comment:10 in reply to:  7 Changed 3 months ago by Ryan J Ollos

Replying to Massimo:

The only tooltip is on the Cc input field but this looks different from the FieldTooltipPlugin. Where is this one defined?

For the case in which you haven't defined the help/cc page, it is defined here: fieldtooltipplugin/0.12/fieldtooltip/fieldtooltip.py@16423:39#L26.

Last edited 3 months ago by Ryan J Ollos (previous) (diff)

comment:11 in reply to:  9 Changed 3 months ago by Massimo

Replying to Ryan J Ollos:

Do a hard refresh of the page and then check the browser console.

14:20:41.799 TypeError: a.browser is undefined1 jquery.tools.min.js:11:629 This browser is Palemoon-27.2.1 on Linux amd64 arch.

comment:12 Changed 3 months ago by Ryan J Ollos

The plugin uses jQuery migrate now, and you should see a message on the console indicating this. From the error message it looks like the library isn't loaded in your browser. You may need to redeploy static resources.

comment:13 Changed 3 months ago by Ryan J Ollos

In 16427:

FieldTooltip 0.7.1: Fix jQuery migrate not included in package

Refs #13033.

comment:14 Changed 3 months ago by Ryan J Ollos

comment:8 issue should be fixed in r16427, but comment:12 still applies.

comment:15 Changed 3 months ago by Ryan J Ollos

In 16428:

FieldTooltip 0.7.2: Replace use of deprecated Context

Refs #13033.

comment:16 Changed 3 months ago by Ryan J Ollos

Resolution: fixed
Status: reopenedclosed

comment:17 in reply to:  14 Changed 3 months ago by anonymous

Replying to Ryan J Ollos:

comment:8 issue should be fixed in r16427, but comment:12 still applies.

Fixed and working. Thanks.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.