treebeard выдало сообщение об ошибке

  • By admin
  • Вс 25 Апрель 2010

После того, как я выложил на рабочий сервер свой проект, часть сайта, доступная простым смертным работала нормально с тестовыми данными. Не работала только закрытая часть, то есть админка. Вернее модуль, позволяющий создавать страницы с текстом сообщал мне об ошибке.

TemplateSyntaxError at /admin/pages/pages/
Caught an exception while rendering: Failed lookup for key [request] in u'[{\'action_index\': 0, \'block\': <Block Node: result_list. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>, <django.template.SimpleNode object at 0x1327a890>, <Text Node: \'\n \'>, <If node>, <Text Node: \'\n\'>]>}, {\'block\': <Block Node: content. Contents: [<Text Node: \'\n <div id="content-main"\'>, <Block Node: object-tools. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>]>, <Text Node: \'\n \'>, <If node>, <Text Node: \'\n <div class="module\'>, <If node>, <Text Node: \'" id="changelist">\n \'>, <Block Node: search. Contents: [<django.template.InclusionNode object at 0x13243310>]>, <Text Node: \'\n \'>, <Block Node: date_hierarchy. Contents: [<django.template.InclusionNode object at 0x132430d0>]>, <Text Node: \'\n\n \'>, <Block Node: filters. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>]>, <Text Node: \'\n \n <form actio\'>, <If node>, <Text Node: \'>\n \'>, <If node>, <Text Node: \'\n\n \'>, <Block Node: result_list. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>, <django.template.SimpleNode object at 0x1327a890>, <Text Node: \'\n \'>, <If node>, <Text Node: \'\n\'>]>, <Text Node: \'\n \'>, <Block Node: pagination. Contents: [<django.template.InclusionNode object at 0x13256a90>]>, <Text Node: \'\n </form>\n </div>\'>]>}, {\'actions_on_bottom\': False, \'cl\': <django.contrib.admin.views.main.ChangeList object at 0x1324ec90>, \'has_add_permission\': True, \'media\': <django.forms.widgets.Media object at 0x1327a450>, \'root_path\': None, \'action_form\': <django.contrib.admin.helpers.ActionForm object at 0x1327a6d0>, \'actions_on_top\': True, \'app_label\': \'pages\', \'is_popup\': False, \'title\': u\'\\u0412\\u044b\\u0431\\u0435\\u0440\\u0438\\u0442\\u0435 pages \\u0434\\u043b\\u044f \\u0438\\u0437\\u043c\\u0435\\u043d\\u0435\\u043d\\u0438\\u044f\'}, {\'this_url\': u\'/admin/pages/pages/\'}, {\'MEDIA_URL\': \'/media/\'}, {\'LANGUAGES\': ((\'ar\', \'Arabic\'), (\'bn\', \'Bengali\'), (\'bg\', \'Bulgarian\'), (\'ca\', \'Catalan\'), (\'cs\', \'Czech\'), (\'cy\', \'Welsh\'), (\'da\', \'Danish\'), (\'de\', \'German\'), (\'el\', \'Greek\'), (\'en\', \'English\'), (\'es\', \'Spanish\'), (\'et\', \'Estonian\'), (\'es-ar\', \'Argentinean Spanish\'), (\'eu\', \'Basque\'), (\'fa\', \'Persian\'), (\'fi\', \'Finnish\'), (\'fr\', \'French\'), (\'ga\', \'Irish\'), (\'gl\', \'Galician\'), (\'hu\', \'Hungarian\'), (\'he\', \'Hebrew\'), (\'hi\', \'Hindi\'), (\'hr\', \'Croatian\'), (\'is\', \'Icelandic\'), (\'it\', \'Italian\'), (\'ja\', \'Japanese\'), (\'ka\', \'Georgian\'), (\'ko\', \'Korean\'), (\'km\', \'Khmer\'), (\'kn\', \'Kannada\'), (\'lv\', \'Latvian\'), (\'lt\', \'Lithuanian\'), (\'mk\', \'Macedonian\'), (\'nl\', \'Dutch\'), (\'no\', \'Norwegian\'), (\'pl\', \'Polish\'), (\'pt\', \'Portuguese\'), (\'pt-br\', \'Brazilian Portuguese\'), (\'ro\', \'Romanian\'), (\'ru\', \'Russian\'), (\'sk\', \'Slovak\'), (\'sl\', \'Slovenian\'), (\'sr\', \'Serbian\'), (\'sv\', \'Swedish\'), (\'ta\', \'Tamil\'), (\'te\', \'Telugu\'), (\'th\', \'Thai\'), (\'tr\', \'Turkish\'), (\'uk\', \'Ukrainian\'), (\'zh-cn\', \'Simplified Chinese\'), (\'zh-tw\', \'Traditional Chinese\')), \'LANGUAGE_BIDI\': False, \'LANGUAGE_CODE\': \'ru\'}, {}, {\'perms\': <django.core.context_processors.PermWrapper object at 0x1327aa50>, \'messages\': [], \'user\': <User: root>}, {}]'
Original Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 908, in render
resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 687, in resolve
value = self._resolve_lookup(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 740, in _resolve_lookup
raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute
VariableDoesNotExist: Failed lookup for key [request] in u'[{\'action_index\': 0, \'block\': <Block Node: result_list. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>, <django.template.SimpleNode object at 0x1327a890>, <Text Node: \'\n \'>, <If node>, <Text Node: \'\n\'>]>}, {\'block\': <Block Node: content. Contents: [<Text Node: \'\n <div id="content-main"\'>, <Block Node: object-tools. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>]>, <Text Node: \'\n \'>, <If node>, <Text Node: \'\n <div class="module\'>, <If node>, <Text Node: \'" id="changelist">\n \'>, <Block Node: search. Contents: [<django.template.InclusionNode object at 0x13243310>]>, <Text Node: \'\n \'>, <Block Node: date_hierarchy. Contents: [<django.template.InclusionNode object at 0x132430d0>]>, <Text Node: \'\n\n \'>, <Block Node: filters. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>]>, <Text Node: \'\n \n <form actio\'>, <If node>, <Text Node: \'>\n \'>, <If node>, <Text Node: \'\n\n \'>, <Block Node: result_list. Contents: [<Text Node: \'\n \'>, <If node>, <Text Node: \'\n \'>, <django.template.SimpleNode object at 0x1327a890>, <Text Node: \'\n \'>, <If node>, <Text Node: \'\n\'>]>, <Text Node: \'\n \'>, <Block Node: pagination. Contents: [<django.template.InclusionNode object at 0x13256a90>]>, <Text Node: \'\n </form>\n </div>\'>]>}, {\'actions_on_bottom\': False, \'cl\': <django.contrib.admin.views.main.ChangeList object at 0x1324ec90>, \'has_add_permission\': True, \'media\': <django.forms.widgets.Media object at 0x1327a450>, \'root_path\': None, \'action_form\': <django.contrib.admin.helpers.ActionForm object at 0x1327a6d0>, \'actions_on_top\': True, \'app_label\': \'pages\', \'is_popup\': False, \'title\': u\'\\u0412\\u044b\\u0431\\u0435\\u0440\\u0438\\u0442\\u0435 pages \\u0434\\u043b\\u044f \\u0438\\u0437\\u043c\\u0435\\u043d\\u0435\\u043d\\u0438\\u044f\'}, {\'this_url\': u\'/admin/pages/pages/\'}, {\'MEDIA_URL\': \'/media/\'}, {\'LANGUAGES\': ((\'ar\', \'Arabic\'), (\'bn\', \'Bengali\'), (\'bg\', \'Bulgarian\'), (\'ca\', \'Catalan\'), (\'cs\', \'Czech\'), (\'cy\', \'Welsh\'), (\'da\', \'Danish\'), (\'de\', \'German\'), (\'el\', \'Greek\'), (\'en\', \'English\'), (\'es\', \'Spanish\'), (\'et\', \'Estonian\'), (\'es-ar\', \'Argentinean Spanish\'), (\'eu\', \'Basque\'), (\'fa\', \'Persian\'), (\'fi\', \'Finnish\'), (\'fr\', \'French\'), (\'ga\', \'Irish\'), (\'gl\', \'Galician\'), (\'hu\', \'Hungarian\'), (\'he\', \'Hebrew\'), (\'hi\', \'Hindi\'), (\'hr\', \'Croatian\'), (\'is\', \'Icelandic\'), (\'it\', \'Italian\'), (\'ja\', \'Japanese\'), (\'ka\', \'Georgian\'), (\'ko\', \'Korean\'), (\'km\', \'Khmer\'), (\'kn\', \'Kannada\'), (\'lv\', \'Latvian\'), (\'lt\', \'Lithuanian\'), (\'mk\', \'Macedonian\'), (\'nl\', \'Dutch\'), (\'no\', \'Norwegian\'), (\'pl\', \'Polish\'), (\'pt\', \'Portuguese\'), (\'pt-br\', \'Brazilian Portuguese\'), (\'ro\', \'Romanian\'), (\'ru\', \'Russian\'), (\'sk\', \'Slovak\'), (\'sl\', \'Slovenian\'), (\'sr\', \'Serbian\'), (\'sv\', \'Swedish\'), (\'ta\', \'Tamil\'), (\'te\', \'Telugu\'), (\'th\', \'Thai\'), (\'tr\', \'Turkish\'), (\'uk\', \'Ukrainian\'), (\'zh-cn\', \'Simplified Chinese\'), (\'zh-tw\', \'Traditional Chinese\')), \'LANGUAGE_BIDI\': False, \'LANGUAGE_CODE\': \'ru\'}, {}, {\'perms\': <django.core.context_processors.PermWrapper object at 0x1327aa50>, \'messages\': [], \'user\': <User: root>}, {}]'

Сделаю небольшое лирическое отступление, treebeard это модуль для django, хранить информацию в виде деревьев. Для решения задачи создания каталога страниц этот модуль очень подходит. Чем он хорош: умеет работать по технологиям nested sets, materialized path и adjacence list. Кроме того, у него отличная документация.

Так вот, из-за плохого чтения оной меня покарал Бог. На домашнем и находящимся на работе компьютером проблем ни каких не возникало.

В документации четко написано, что если используете в этот модуль в блоке администраторов, то нужно прописать путь TEMPLATE_DIRS до шаблонов treebeard (в моем случае это /usr/lib/python2.5/site-packages/treebeard/templates/) а также добавить django-core-context-processors-request в TEMPLATE_CONTEXT_PROCESSORS