Modify

Opened 3 months ago

Closed 22 hours 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 weeks ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 3 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 3 months ago by Massimo

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

Changed 4 weeks ago by Ryan J Ollos

Attachment: t13033.patch added

comment:3 Changed 4 weeks ago by Ryan J Ollos

Please try t13033.patch.

comment:4 Changed 4 weeks 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 22 hours 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 22 hours 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.

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.