make html すると UndefinedError が発生

date:2013-04-14
status:close
type:bug

結論

layout.html 内に pathto と書こうとして path と書いていました。 そのためテンプレート内に間違った記述があるとして UndefinedError が発生していました。 layout.html 内の pathpathto に修正しました。

内容

自作のテーマ oldschool を作成中に make html すると UndefinedError が発生するようになりました。

$ make html
Running Sphinx v1.1.3
loading translations [ja]... done
loading pickled environment... done
building [html]: targets for 4 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
preparing documents... done
writing output... [ 25%] index

Exception occurred:
  File "/usr/opt/lib/python27/site-packages/jinja2/sandbox.py", line 276, in is
_safe_callable
    return not (getattr(obj, 'unsafe_callable', False) or
UndefinedError: 'path' is undefined
The full traceback has been saved in /tmp/sphinx-err-onllzv.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message c
an be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-d
ev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/
>. Thanks!

エラーログも掲載します。

$ cat /tmp/sphinx-err-onllzv.log
# Sphinx version: 1.1.3
# Python version: 2.7.3
# Docutils version: 0.10 release
# Jinja2 version: 2.6
Traceback (most recent call last):
  File "/usr/lib/python27/site-packages/sphinx/cmdline.py", line 189, in main
    app.build(force_all, filenames)
  File "/usr/lib/python27/site-packages/sphinx/application.py", line 204, in build
    self.builder.build_update()
  File "/usr/lib/python27/site-packages/sphinx/builders/__init__.py", line 196, in build_update
    'out of date' % len(to_build))
  File "/usr/lib/python27/site-packages/sphinx/builders/__init__.py", line 252, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/lib/python27/site-packages/sphinx/builders/__init__.py", line 292, in write
    self.write_doc(docname, doctree)
  File "/usr/lib/python27/site-packages/sphinx/builders/html.py", line 426, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/usr/lib/python27/site-packages/sphinx/builders/html.py", line 728, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/usr/lib/python27/site-packages/sphinx/jinja2glue.py", line 128, in render
    return self.environment.get_template(template).render(context)
  File "D:/ng/opt/python27/lib/site-packages/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python27/site-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {% extends "layout.html" %}
  File "D:/ng/home/sximadaw3/_theme/oldschool/layout.html", line 11, in top-level template code
    {% extends "agogo/layout.html" %}
  File "/usr/lib/python27/site-packages/sphinx/themes/agogo/layout.html", line 11, in top-level template code
    {% extends "basic/layout.html" %}
  File "/usr/lib/python27/site-packages/sphinx/themes/basic/layout.html", line 156, in top-level template code
    {%- block header %}{% endblock %}
  File "/home/sximadaw3/_theme/oldschool/layout.html", line 19, in block "header"
    <li><a href="{{ path('work/index') }}">WORK</li>
  File "D:/ng/opt/python27/lib/site-packages/jinja2/sandbox.py", line 347, in call
    if not __self.is_safe_callable(__obj):
  File "D:/ng/opt/python27/lib/site-packages/jinja2/sandbox.py", line 276, in is_safe_callable
    return not (getattr(obj, 'unsafe_callable', False) or
UndefinedError: 'path' is undefined

テンプレートのエラーのようです。 layout.html 内の次の行がダメみたいです。

<li><a href="{{ path('work/index') }}">WORK</li>

!? これははおかしいですね。:

{{ path('work/index') }}

正しくはこうです。:

{{ pathto('work/index') }}

目次

前のトピックへ

issueがリンクされない

次のトピックへ

サイトをロードすると意図しない通信が発生

このページ

inserted by FC2 system