Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#13179 closed defect (fixed)

Macro errors in combine use with WikiAutoCompletePlugin

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

Description

The macros crash when the plugin description is rendering inside the WikiAutoCompletePlugin popup.

2017-05-13 01:15:15,464 Trac[formatter] ERROR: Macro SiblingPage(None) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 356, in process
    text = self.processor(text)
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 340, in _macro_processor
    text, self.args)
  File "build/bdist.linux-x86_64/egg/neighborpage/nav.py", line 74, in expand_macro
    prefix = '/' in page and page[:page.rindex('/') + 1] or ''
TypeError: argument of type 'NoneType' is not iterable
2017-05-13 01:15:15,465 Trac[formatter] ERROR: Macro SiblingPage(Prev, Next) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 356, in process
    text = self.processor(text)
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 340, in _macro_processor
    text, self.args)
  File "build/bdist.linux-x86_64/egg/neighborpage/nav.py", line 74, in expand_macro
    prefix = '/' in page and page[:page.rindex('/') + 1] or ''
TypeError: argument of type 'NoneType' is not iterable
2017-05-13 01:15:15,466 Trac[formatter] ERROR: Macro PreviousPage(Prev, Next) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 356, in process
    text = self.processor(text)
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 340, in _macro_processor
    text, self.args)
  File "build/bdist.linux-x86_64/egg/neighborpage/nav.py", line 74, in expand_macro
    prefix = '/' in page and page[:page.rindex('/') + 1] or ''
TypeError: argument of type 'NoneType' is not iterable
2017-05-13 01:15:15,467 Trac[formatter] ERROR: Macro SiblingPage($PageName) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 356, in process
    text = self.processor(text)
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 340, in _macro_processor
    text, self.args)
  File "build/bdist.linux-x86_64/egg/neighborpage/nav.py", line 74, in expand_macro
    prefix = '/' in page and page[:page.rindex('/') + 1] or ''
TypeError: argument of type 'NoneType' is not iterable
2017-05-13 01:15:15,469 Trac[formatter] ERROR: Macro SiblingPage(Minutes($PageName)) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 356, in process
    text = self.processor(text)
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 340, in _macro_processor
    text, self.args)
  File "build/bdist.linux-x86_64/egg/neighborpage/nav.py", line 74, in expand_macro
    prefix = '/' in page and page[:page.rindex('/') + 1] or ''
TypeError: argument of type 'NoneType' is not iterable

Attachments (6)

Screen Shot 2017-05-19 at 18.38.05.png (77.5 KB) - added by Ryan J Ollos 7 years ago.
t13179.diff (2.0 KB) - added by Ryan J Ollos 7 years ago.
Screen Shot 2017-05-24 at 10.23.15.png (111.0 KB) - added by Ryan J Ollos 7 years ago.
Capture.png (39.4 KB) - added by ntmlod 7 years ago.
Issue with NeighborPage macros in WikiautoCompletePlugin popup
Capture-1.png (124.1 KB) - added by ntmlod 7 years ago.
Screenshot from WikiStart page
t13179.2.diff (1.0 KB) - added by Ryan J Ollos 7 years ago.

Download all attachments as: .zip

Change History (34)

comment:1 Changed 7 years ago by ntmlod

Keywords: autocomplete added
Summary: Macro errors used withMacro errors in combine use with WikiAutoCompletePlugin

Changed 7 years ago by Ryan J Ollos

Changed 7 years ago by Ryan J Ollos

Attachment: t13179.diff added

comment:2 Changed 7 years ago by Ryan J Ollos

Component: NeighborPagePluginWikiAutoCompletePlugin
Owner: changed from matobaa to Peter Suter

Confirmed.

We can fix this by populating the Resource in the RenderingContext: t13179.diff.

comment:3 Changed 7 years ago by Peter Suter

Patch look good to me.

comment:4 Changed 7 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 16602:

WikiAutoCompletePlugin 1.3: Add resource to rendering context

This fixes an error rendering a macro or processor preview.

Fixes #13179.

comment:5 Changed 7 years ago by Ryan J Ollos

Thanks for fast review!

comment:6 Changed 7 years ago by ntmlod

Resolution: fixed
Status: closedreopened

Thanks for the patch, I have updated both WikiAutoCompletePlugin and NeighborPagePlugin

There is improvement as WikiMacros local page doesn't show anymore the errors but I still get the same issues in the popup.

2017-05-24 15:20:24,905 Trac[formatter] ERROR: Macro SiblingPage(None) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 356, in process
    text = self.processor(text)
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 340, in _macro_processor
    text, self.args)
  File "build/bdist.linux-x86_64/egg/neighborpage/nav.py", line 76, in expand_macro
    prefix = '/' in page and page[:page.rindex('/') + 1] or ''
TypeError: argument of type 'NoneType' is not iterable
2017-05-24 15:20:24,908 Trac[formatter] ERROR: Macro PreviousPage(Prev, Next) failed:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 356, in process
    text = self.processor(text)
  File "/usr/lib/python2.7/site-packages/trac/wiki/formatter.py", line 340, in _macro_processor
    text, self.args)
  File "build/bdist.linux-x86_64/egg/neighborpage/nav.py", line 76, in expand_macro
    prefix = '/' in page and page[:page.rindex('/') + 1] or ''
TypeError: argument of type 'NoneType' is not iterable
Last edited 7 years ago by Jun Omae (previous) (diff)

comment:7 Changed 7 years ago by Ryan J Ollos

Did you do a hard refresh of the page to updated cached resources?

comment:8 Changed 7 years ago by ntmlod

I got the same result with 2 different sessions of Firefox (my admin session and user session).
I cleared the cache on both but not good another time.

comment:9 Changed 7 years ago by Ryan J Ollos

Does the script at /chrome/wikiautocomplete/js/wikiautocomplete.js match wikiautocompleteplugin/trunk/wikiautocomplete/htdocs/js/wikiautocomplete.js? It should have the changes: [16602#file1].

comment:10 Changed 7 years ago by ntmlod

[xxxx@xxxxxxxxxx wikiautocompleteplugin]$ svn info wikiautocomplete/htdocs/js/wikiautocomplete.js 
Chemin : wikiautocomplete/htdocs/js/wikiautocomplete.js
Nom : wikiautocomplete.js
Chemin racine de la copie de travail : *****************************************/wikiautocompleteplugin
URL : https://trac-hacks.org/svn/wikiautocompleteplugin/trunk/wikiautocomplete/htdocs/js/wikiautocomplete.js
Relative URL: ^/wikiautocompleteplugin/trunk/wikiautocomplete/htdocs/js/wikiautocomplete.js
Racine du dépôt : https://trac-hacks.org/svn
UUID du dépôt : 7322e99d-02ea-0310-aa39-e9a107903beb
Révision : 16611
Type de nœud : fichier
Tâche programmée : normale
Auteur de la dernière modification : rjollos
Révision de la dernière modification : 16602
Date de la dernière modification: 2017-05-20 09:11:25 +0200 (sam. 20 mai 2017)
Texte mis à jour: 2017-05-24 15:05:03 +0200 (mer. 24 mai 2017)
Somme de contrôle : 586c1f1d6c2ca745f1643cdfaa94784a73aba061
Last edited 7 years ago by ntmlod (previous) (diff)

comment:11 Changed 7 years ago by Ryan J Ollos

Please check if the script served by your webserver matches the one in the repository. Navigate to /chrome/wikiautocomplete/js/wikiautocomplete.js relative to your project base URL.

comment:12 Changed 7 years ago by ntmlod

Thanks for the relative path to js script. I guess you can check it directly online at the following URL: http://forge.ipsl.jussieu.fr/nemo/chrome/wikiautocomplete/js/wikiautocomplete.js

comment:13 Changed 7 years ago by ntmlod

A repeated warning present in the log but I'm not sure if it is related

2017-05-24 16:28:42,318 Trac[chrome] WARNING: File js/dist/jquery.textcomplete.min.map not found in any of ['/var/www/.python-eggs/WikiAutoComplete-1.3-py2.7.egg-tmp/wikiautocomplete/htdocs']

comment:14 Changed 7 years ago by Jun Omae

NeighborPagePlugin's macros are available only in wiki page. Then, we should check whether formatter.resource.realm is 'wiki'.

  • neighborpageplugin/1.0/neighborpage/nav.py

    diff --git a/neighborpageplugin/1.0/neighborpage/nav.py b/neighborpageplugin/1.0/neighborpage/nav.py
    index 4373ac9a7..5a0ba322d 100644
    a b from trac.util.translation import _ 
    1414from trac.web.api import IRequestFilter
    1515from trac.web.chrome import prevnext_nav, add_link
    1616from trac.wiki.api import WikiSystem, parse_args
     17from trac.wiki.formatter import system_message
    1718from trac.wiki.macros import WikiMacroBase
    1819
    1920
    class Macro(WikiMacroBase): 
    7273
    7374        content = [len(content) == 0 and _('Previous Page') or content[0],
    7475                   len(content) == 0 and _('Next Page') or len(content) == 1 and content[0] or content[1]]
     76        if formatter.resource.realm != 'wiki':
     77            return system_message("Macro %s is available in wiki page" % name)
    7578        page = formatter.resource.id
    7679        prefix = '/' in page and page[:page.rindex('/') + 1] or ''
    7780        tier = prefix.count('/')

comment:15 Changed 7 years ago by Ryan J Ollos

In 16612:

NeighborPagePlugin 0.4: Issue error message if used in non-wiki realm

Patch by Jun Omae.

Refs #13179.

Changed 7 years ago by Ryan J Ollos

comment:16 in reply to:  13 ; Changed 7 years ago by Ryan J Ollos

Replying to ntmlod:

A repeated warning present in the log but I'm not sure if it is related

2017-05-24 16:28:42,318 Trac[chrome] WARNING: File js/dist/jquery.textcomplete.min.map not found in any of ['/var/www/.python-eggs/WikiAutoComplete-1.3-py2.7.egg-tmp/wikiautocomplete/htdocs']

Not sure why that warning would be occurring. The only reference to the source map is commented out.

comment:17 Changed 7 years ago by Ryan J Ollos

If you still have trouble using the macro in a wiki page, please show a screen capture. Here is what I get:

comment:18 in reply to:  16 Changed 7 years ago by Jun Omae

Replying to Ryan J Ollos:

Not sure why that warning would be occurring. The only reference to the source map is commented out.

The // sourceMappingURL=... line is used by javascript debugger to retrieve the original source for minified javascript source.

See also Use a source map - Firefox Developer Tools | MDN.

Changed 7 years ago by ntmlod

Attachment: Capture.png added

Issue with NeighborPage macros in WikiautoCompletePlugin popup

comment:19 Changed 7 years ago by ntmlod

Well something is going wrong here because I got exactly the error message

Issue with NeighborPage macros in WikiautoCompletePlugin popup

Last edited 7 years ago by ntmlod (previous) (diff)

comment:20 in reply to:  19 Changed 7 years ago by Ryan J Ollos

Replying to ntmlod:

Well something is going wrong here because I got exactly the error message

What is the path for the page where you see the error?

Changed 7 years ago by ntmlod

Attachment: Capture-1.png added

Screenshot from WikiStart page

comment:21 Changed 7 years ago by ntmlod

Nothing particular i.e. ${base_url}/wiki/user/nemo, my try was for a non-existing wiki page but same result from WikiStart page

Screenshot from WikiStart page

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:22 in reply to:  6 Changed 7 years ago by Ryan J Ollos

Replying to ntmlod:

Thanks for the patch, I have updated both WikiAutoCompletePlugin and NeighborPagePlugin

There is improvement as WikiMacros local page doesn't show anymore the errors but I still get the same issues in the popup.

Unrelated, created trac:#12820 to improve logging.

p.s. just noticed use of logtalk WikiProcessor. That one is new to me.

comment:23 in reply to:  21 Changed 7 years ago by Ryan J Ollos

Replying to ntmlod:

Nothing particular i.e. ${base_url}/wiki/user/nemo, my try was for a non-existing wiki page but same result from WikiStart page

I can reproduce with Trac 1.0.1. Investigating...

Changed 7 years ago by Ryan J Ollos

Attachment: t13179.2.diff added

comment:24 Changed 7 years ago by Ryan J Ollos

context isn't available in the data dictionary prior to Trac 1.0.2 (trac:r12157).

Proposed fix: t13179.2.diff

Please consider upgrading to Trac 1.0.13. It's tedious to debug and test older versions of Trac.

comment:25 Changed 7 years ago by ntmlod

Resolution: fixed
Status: reopenedclosed

Thanks a lot rjollos, you finally overcome this ;-)

I should think about giving you the contact details of our forge webmaster to support my own lobbying on the upgrade of our global installation.

comment:26 in reply to:  24 Changed 7 years ago by Ryan J Ollos

Replying to Ryan J Ollos:

Proposed fix: t13179.2.diff

@psuter Are you okay with this change, or would you prefer to only support Trac >= 1.0.2?

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:27 Changed 7 years ago by Peter Suter

The patch seems fine, feel free to commit it.

comment:28 Changed 7 years ago by Ryan J Ollos

In 16614:

WikiAutoCompletePlugin 1.3: Add support for Trac < 1.0.2

The context is not in the data dictionary prior
to Trac 1.0.2 (trac:r12157).

Fixes #13179.

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.