Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13439 closed defect (fixed)

AttributeError: 'int' object has no attribute 'resource'

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Component: WikiAutoCompletePlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

Reported by Nicolas Martin (ntmlod):

Spam filter plugin ... crash: 'Monitoring' (/admin/spamfilter/monitor) and 'Reports' (/admin/spamfilter/report). But the log refers to WikiAutoCompletePlugin

2018-06-10 20:57:39,539 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 224, in dispatch
    self._post_process_request(req, *resp)
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 338, in _post_process_request
    resp = f.post_process_request(req, *resp)
  File "build/bdist.linux-x86_64/egg/wikiautocomplete/web_ui.py", line 60, in post_process_request
    if context_or_page and context_or_page.resource:
AttributeError: 'int' object has no attribute 'resource' 

source:wikiautocompleteplugin/trunk/wikiautocomplete/web_ui.py@17075:59-62#L43 is not working with data['page'] of type int in e.g. trac:source:plugins/1.0/spam-filter/tracspamfilter/admin.py@16487:97,211,239,243#L211

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by Peter Suter

Maybe we should do something like this?

             context_or_page = data.get('context') or data.get('page')
-            if context_or_page and context_or_page.resource:
+            if (context_or_page and hasattr(context_or_page, 'resource')
+                and context_or_page.resource):
                 script_data['realm'] = context_or_page.resource.realm
                 script_data['id'] = context_or_page.resource.id

comment:2 Changed 6 years ago by Ryan J Ollos

The patch looks good to me.

comment:3 Changed 6 years ago by Peter Suter

In 17198:

WikiAutoCompletePlugin: Avoid problems with SpamFilterPlugin where page is int.
(see #13439)

comment:4 Changed 6 years ago by Peter Suter

Resolution: fixed
Status: newclosed

Thanks.

Last edited 6 years ago by Peter Suter (previous) (diff)

comment:5 Changed 6 years ago by ntmlod

Checked, it's fine :-)

Thanks.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Suter.
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.