Description

When including a Table of Contents on a page, and there is a table on the same page which includes a combined cell, I get the following Error:

<<TableOfContents: execution failed [cannot import name AS_IS] (see also the log)>>

When there are only single cells, the Table of Contents is shown as expected.

Steps to reproduce

The following code gives an error:

<<TableOfContents>>

||<-2> test ||
|| test || test ||

This code works fine:

<<TableOfContents>>

|| test || test ||
|| test || test ||

Example

Component selection

Details

MoinMoin Version

1.9.3

OS and Version

Debian Linux

Python Version

2.5.2

Server Setup

Apache server with wiki in home folder

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

en

Workaround

Discussion

Please attach the full traceback from the log file.

Traceback

2010-08-02 15:00:05,081 MoinMoin.macro ERROR Macro TableOfContents (page: 'linuxProgramming') raised an exception:
Traceback (most recent call last):
  File "/home/user/lib/python/MoinMoin/macro/__init__.py", line 122, in execute
    return execute(self, args)
  File "/home/user/lib/python/MoinMoin/macro/__init__.py", line 107, in <lambda>
    _self.request, call, _args, [_self])
  File "/home/user/lib/python/MoinMoin/wikiutil.py", line 1954, in invoke_extension_function
    return function(*fixed_args, **kwargs)
  File "/home/user/lib/python/MoinMoin/macro/TableOfContents.py", line 165, in macro_TableOfContents
    omit_footnotes=True)
  File "/home/user/lib/python/MoinMoin/web/contexts.py", line 296, in redirectedOutput
    function(*args, **kw)
  File "/home/user/lib/python/MoinMoin/Page.py", line 1198, in send_page
    start_line=pi['lines'])
  File "/home/user/lib/python/MoinMoin/Page.py", line 1288, in send_page_content
    self.format(parser)
  File "/home/user/lib/python/MoinMoin/Page.py", line 1309, in format
    parser.format(self.formatter)
  File "/home/user/lib/python/MoinMoin/parser/text_moin_wiki.py", line 1554, in format
    formatted_line = self.scan(line, inhibit_p=inhibit_p)
  File "/home/user/lib/python/MoinMoin/parser/text_moin_wiki.py", line 1364, in scan
    result.append(self.replace(match, inhibit_p))
  File "/home/user/lib/python/MoinMoin/parser/text_moin_wiki.py", line 1408, in replace
    result.append(replace_func(hit, match.groupdict()))
  File "/home/user/lib/python/MoinMoin/parser/text_moin_wiki.py", line 1167, in _table_repl
    attrs, attrerr = self._getTableAttrs(word)
  File "/home/user/lib/python/MoinMoin/parser/text_moin_wiki.py", line 1144, in _getTableAttrs
    attr, msg = wikiutil.parseAttributes(self.request, attrdef, '>', table_extension)
  File "/home/user/lib/python/MoinMoin/wikiutil.py", line 1996, in parseAttributes
    found_flag, msg = extension(key, parser, attrs)
  File "/home/user/lib/python/MoinMoin/parser/text_moin_wiki.py", line 1141, in table_extension
    return found, self.formatter.rawHTML(msg)
  File "/home/user/lib/python/MoinMoin/formatter/__init__.py", line 371, in rawHTML
    import formatter, htmllib
  File "/usr/lib/python2.5/htmllib.py", line 9, in <module>
    from formatter import AS_IS
ImportError: cannot import name AS_IS

Explanation

In the sys.path variable are two locations where a "formatter" is found, one in the standard installation, one in the MoinMoin installation. These scripts/modules conflict in namespace.

There is a file /usr/lib/python2.5/formatter.py which includes a AS_IS, which htmllib depends on, but due to MoinMoin formatter which is also in the namespace, htmllib mistakenly directs to the MoinMoin formatter.

This error is described om the Python webpage: As chapter 6.2.1 from http://docs.python.org/tutorial/modules.html tells, a script should not have the same name as a standard module otherwise errors can occur.

Workaround for my installation

If I add the following lines to /home/user/lib/python/MoinMoin/formatter/init.py before line 371, it works fine:

    371         import sys
    372         if '/home/user/lib/python/MoinMoin' in sys.path:
    373             sys.path.remove('/home/user/lib/python/MoinMoin')

Solution

There was a misconfiguration in the moin.cgi file. It was mistakenly added /home/user/lib/python/MoinMoin to sys.path.

Plan


CategoryMoinMoinBug

MoinMoin: MoinMoinBugs/TableOfContentsImportErrorIfCombinedTableCell (last edited 2010-08-04 14:05:29 by JohannesSchrimpf)