Просмотр пользовательского типа контента Plone дает AttributeError: у объекта 'NoneType' нет атрибута 'getPhysicalPath' - PullRequest
0 голосов
/ 11 августа 2011

С большой помощью (я неопытный программист / разработчик Plone) я создал несколько пользовательских типов контента на новом веб-сайте Plone.Я сейчас испытываю ошибку.Тип контента называется «Организация» и имеет необязательное многозначное ссылочное поле с «разрешенным типом» сайта (другой из моих пользовательских типов контента).Я создал много записей организации;все хорошо.Затем я связал некоторые из них с сайтами.Они сохранены в порядке, но сейчас, через неделю или две, когда я пытаюсь просмотреть любой из них, я получаю следующее сообщение об ошибке:

Traceback (самый последний внутри):

Module ZPublisher.Publish, line 127, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 47, in call_object
Module Products.Five.browser.metaconfigure, line 477, in __call__
Module Products.Five.browser.pagetemplatefile, line 126, in __call__
Module Products.Five.browser.pagetemplatefile, line 60, in __call__
Module zope.pagetemplate.pagetemplate, line 113, in pt_render
Module zope.tal.talinterpreter, line 271, in __call__
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 888, in do_useMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 954, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 858, in do_defineMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 954, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 946, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 858, in do_defineMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 888, in do_useMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 852, in do_condition
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 852, in do_condition
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 821, in do_loop_tal
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 583, in do_setLocal_tal
Module zope.tales.tales, line 696, in evaluate
URL: file:/usr/local/Plone/buildout-cache/eggs/archetypes.referencebrowserwidget-2.1-py2.6.egg/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.pt
Line 57, Column 12
Expression: <PythonExpr '/'.join(obj.getPhysicalPath())>
Names:

{'args': (),
 'container': <Organisation at /ecn/what-we-do/about/sponsors/ccw>,
 'context': <Organisation at /ecn/what-we-do/about/sponsors/ccw>,
 'default': <object object at 0xb75f86d0>,
 'here': <Organisation at /ecn/what-we-do/about/sponsors/ccw>,
 'loop': {},
 'nothing': None,
 'options': {},
 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0xcadb89c>,
 'request': <HTTPRequest, URL=http://la-ecnweb1.nerc-lancaster.ac.uk:8080/ecn/what-we-do/about/sponsors/ccw/organisation_view>,
 'root': <Application at >,
 'template': <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0xaa4154c>,
 'traverse_subpath': [],
 'user': <PropertiedUser 'admin'>,
 'view': <Products.Five.metaclass.SimpleViewClass from /usr/local/Plone/zinstance/src/ceh.ecn_theme/ceh/ecn_theme/browser/templates/organisation_view.pt object at 0xc926aec>,
 'views': <Products.Five.browser.pagetemplatefile.ViewMapper object at 0xc926aac>}

Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
__traceback_info__: '/'.join(obj.getPhysicalPath())
Module PythonExpr, line 1, in <expression>

AttributeError: 'Объект NoneType не имеет атрибута «getPhysicalPath»

«Организации», которые не ссылаются на сайт, отображаются нормально.Кто-нибудь может подсказать в чем может быть проблема?Я задавался вопросом, была ли это проблема с индексом, поэтому попытался обновить portal_catalog, reference_catalog и uid_catalog, но это не помогло.

Странно, я создал новую «Организацию» и связал ее с «Сайтом» иэто работает отлично.Кроме того, я протестировал все свои пользовательские типы и шаблоны на локальном экземпляре Plone на своем ноутбуке, и там все отлично работает.Как будто что-то повредило эти конкретные объекты с момента их первого создания.

Пожалуйста, сообщите, если вам нужно, чтобы я отправил любой код, и я сделаю.

Спасибо.

Ответы [ 3 ]

3 голосов
/ 11 августа 2011

Если вы переместили организации каким-либо способом, который обошел механизм, используемый для обновления ссылок, или если этот механизм был каким-то образом поврежден, это могло бы объяснить проблемы. Я думаю, что очистка reference_catalog и uid_catalog с последующим "Очистить и перестроить" portal_catalog, вероятно, решит вашу проблему. Вы найдете эту кнопку под «Обновить каталог» в середине той же страницы в ZMI портала_каталога. Процесс «Обновление каталога» предполагает, что каталог уже правильно знает, где находятся все объекты, подлежащие индексации, но в этом-то и заключается проблема: один или несколько каталогов не были обновлены в том месте, где находятся ваши «сайты». Вот тут и появляется «Очистить и перестроить». Из документации на этой странице в ZMI:

Clear and Rebuild will remove all entries from the catalog, and then walk the entire portal looking for content objects which should be indexed in the catalog and index them. Doing this will remove inappropriate entries from the portal catalog (scripts, templates) and preserve all indexed content. This may take a long time, but it is the correct way to rebuild a catalog that has had objects improperly added or removed.

Если это не сработает, или если вам просто любопытно, вам нужно выяснить, какая ссылка вызывает проблему. Найдите пример «Organization» с ошибкой, запустите отладчик с помощью что-то вроде «bin / instance debug», затем выполните что-то вроде:

>>> portal = app.unrestrictedTraverse('/portal_name')
>>> org = portal.unrestrictedTraverse('path/to/buggy/organization') # no leading slash
>>> broken = [item for item in org.getReferenceImpl(field_relationship) if item.getTargetObject() is None]
>>> brains = portal.uid_catalog.unrestrictedSearchResults(UID=[item.targetUID for item in broken])
>>> from pprint import pprint
>>> pprint([brain.getPath() for brain in brains])

Это должно вывести список путей, по которым каталог задействован считает, сайты находятся. Вы можете проверить это и увидеть больше того, что происходит. Вы также можете больше разбираться в том, что находится в списках «разбитых» и «мозгов», чтобы узнать больше о том, что происходит.

1 голос
/ 11 августа 2011

Кажется, что упомянутого объекта больше нет.Он не может быть найден UUID, поэтому где-то в reference_catalog возвращается None (_objectByUUID).

Я думаю, archetypes.referencebrowserwidget должен обрабатывать этот случай, но это не так.на какой сайт вы ссылались?Это все еще там?Вы можете как-то отбросить ссылку и воссоздать ее?

Cheers

0 голосов
/ 15 июня 2015

Была похожая проблема: похоже, что-то не работало в "системе ссылок", когда ссылка на страницу была отменена. Страница была помечена как нераскрытая

Переопределение файла referencebrowser.pt Изменение строки со 164 на 172 решает мою проблему

в архетипах / referencebrowserwidget / skins / referencebrowser / referencebrowser.pt

<label tal:define="title set/title_or_id | string:Undisclosed;
                   obj_path python: set and '/'.join(set.getPhysicalPath()) or None;">
   <input type="checkbox" 
          tal:attributes="name string:${fieldName}:list;
                          value python:helper.getUidFromReference(set);
                          checked python: set and 'checked' or None;
                          style python: not set and 'display:none' or None;" 
           checked="checked" />
...