Hi there,
I'm having a problem when parsing a string; mwlib is throwing an error
that I'm not sure how to deal with to wit, here's the trace, beginning
with a call I made to "parseString". The database that's being used is
a wrapper on a django sqlite database that knows how to go get new
templates from the web, and it passes all of the other tests I've
thrown at it (i.e. it can expand templates and convert links and
other basic syntax properly).
Nevertheless, I'm getting this error:
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-linux-
i686.egg/mwlib/refine/uparser.py", line 34, in parseString
input = te.expandTemplates(True)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 291, in expandTemplates
return self._expand(self.parsed, keep_uniq=keep_uniq)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 278, in _expand
flatten(parsed, self, ArgumentList(expander=self), res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 28, in flatten
flatten(x, expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 30, in flatten
node.flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 205, in flatten
return self._flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 282, in _flatten
flatten(p, expander, var, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 28, in flatten
flatten(x, expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 30, in flatten
node.flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 205, in flatten
return self._flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 282, in _flatten
flatten(p, expander, var, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 28, in flatten
flatten(x, expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 30, in flatten
node.flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 75, in flatten
flatten(self[3], expander, variables, tmp)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 28, in flatten
flatten(x, expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 30, in flatten
node.flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 205, in flatten
return self._flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 282, in _flatten
flatten(p, expander, var, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 28, in flatten
flatten(x, expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/evaluate.py", line 30, in flatten
node.flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 205, in flatten
return self._flatten(expander, variables, res)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/nodes.py", line 268, in _flatten
rep = expander.resolver(name, var)
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/magics.py", line 554, in __call__
res = m(args) or '' # FIXME: catch TypeErros
File "/usr/local/lib/python2.6/dist-packages/mwlib-0.12.13-py2.6-
linux-i686.egg/mwlib/templ/magics.py", line 310, in NS
namespaces = self.source.namespaces or {}
AttributeError: 'dict' object has no attribute 'namespaces'
I tried to trace it back: that's from a method in the PageMagic class.
The first line of that class is:
"class PageMagic(object):
source={}
"
But there's no other mention of source in it, so I don't understand
how it could ever have the property "namespaces". Therefore, two
points:
1. Is this is a bug? I don't see how, if that NS function is ever
called, it could result in anything OTHER than an error, but I don't
want to call 'bug' unnecessarily.
2. That function being called definitely depends on what I ask it to
parse, but I don't know what's causing the error. I'm not certain how
to debug it. Right before it breaks, the last three templates that
started parsing were:
fact
R from other template
Tlx
I thus presume it's something inside "R from other template" or "Tlx",
but I don't know what it could be. (these are all standard english
wikipedia templates, by the way).
Here's the Tlx content, in case that's useful:
"<includeonly><tt><nowiki>{{</nowiki>{{#if:{{{subst|}}}|
[[Help:Substitution|subst]]:}}[[{{{LANG|}}}{{{SISTER|}}}
{{ns:Template}}:{{{1|}}}|{{{1|}}}]]<!--\n-->{{#if:{{{2|}}}|\n|
{{{2}}}\n}}<!--\n-->{{#if:{{{3|}}}|\n|{{{3}}}\n}}<!--\n-->{{#if:
{{{4|}}}|\n|{{{4}}}\n}}<!--\n-->{{#if:{{{5|}}}|\n|{{{5}}}\n}}
<!--\n-->{{#if:{{{6|}}}|\n|{{{6}}}\n}}<!--\n-->{{#if:{{{7|}}}|
\n|{{{7}}}\n}}<!--\n-->{{#if:{{{8|}}}|\n|{{{8}}}\n}}<!--\n--
>{{#if:{{{9|}}}|\n|{{{9}}}\n}}<!--\n-->{{#if:{{{10|}}}|\n|
{{{10}}}\n}}<!--\n-->{{#if:{{{11|}}}|\n|{{{11}}}\n}}<!--\n--
>{{#if:{{{12|}}}|\n|''...''\n}}<nowiki>}}</nowiki></tt></
includeonly><noinclude>\n\n{{documentation}}\n<!-- Add categories and
interwikis to the /doc subpage, not here! -->\n</noinclude>"
If there's anything you can suggest, I'd much appreciate it.
Thanks so much,
Peter
PS:
Joel, if you're reading this, thanks so much for all the help in the
other thread. It took me a long time to actually understand everything
you said, but I finally think I do. I would not have got this far
without it. Cheers!
--
You received this message because you are subscribed to the Google Groups
"mwlib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/mwlib?hl=en.