如何让 CMFEditions“查看此修订版”适用于在 Plone 中使用 BrowserView 的项目

发布于 2024-12-01 10:37:24 字数 3971 浏览 1 评论 0原文

我有一个使用 BrowserView 定义的新闻项目的自定义模板,覆盖 Plone 皮肤层中的默认模板。我们还安装了 CMFEditions。尝试查看以前的版本会导致错误,如 Plone bug 中所述。我们正在升级到 Plone 3.3.6,因此“修复”描述已经到位,但我仍然看到“查看此修订版”链接,它仍然会导致错误

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Products.PloneHotfix20110531, line 106, in _patched_bindAndExec
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CacheSetup.patch_cmf, line 51, in FSPT_pt_render
  Module Products.CacheSetup.patch_cmf, line 126, in PT_pt_render
   - Warning: Macro expansion failed
   - Warning: exceptions.KeyError: 'view_macro'
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 949, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 855, in do_condition
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 822, in do_loop_tal
  Module zope.tales.tales, line 685, in setRepeat
  Module zope.tales.tales, line 101, in __init__
TypeError: iteration over non-sequence

我的问题是如何更改我的模板来让它工作。 BrowserView 使用的模板文件与原始文件非常匹配,并定义了一个主宏。我很确定它没有问题,就好像我用下面的空白模板替换它一样,我仍然得到完全相同的错误。

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="plone">
<body>
<div metal:fill-slot="main">
    <tal:main-macro metal:define-macro="main">
    </tal:main-macro>
</div>
</body>
</html>

使用 Products.PDBDebugMode 我可以进一步调试并发现

TypeError: iteration over non-sequence
> c:\plone\parts\zope2\lib\python\zope\tales\tales.py(101)__init__()
-> self._iter = i = iter(seq)
(Pdb) a
self = <Products.PageTemplates.Expressions.PathIterator object at 0x0B2FE350>
name = vdata
seq = <Products.CMFEditions.ZVCStorageTool.ShadowHistory object at 0x0B28C370>
context = <Products.PageTemplates.Expressions.ZopeContext object at 0x0B2E3DD0>

seq 这里没有 itergetitem 方法,因此 iter() 引发 TypeError。此错误源自 versions_history_form.pt

<tal:block repeat="vdata history">

I have a custom template for news items defined using a BrowserView overriding the default template in Plone's skin layer. We also have CMFEditions installed. Trying to view a previous revision results in an error as discussed in this Plone bug. We're in the process of upgrading to Plone 3.3.6 so the "fix" describe there is in place but I'm still seeing the "view this revision" link and it still results in an error

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Products.PloneHotfix20110531, line 106, in _patched_bindAndExec
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CacheSetup.patch_cmf, line 51, in FSPT_pt_render
  Module Products.CacheSetup.patch_cmf, line 126, in PT_pt_render
   - Warning: Macro expansion failed
   - Warning: exceptions.KeyError: 'view_macro'
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 949, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 855, in do_condition
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 822, in do_loop_tal
  Module zope.tales.tales, line 685, in setRepeat
  Module zope.tales.tales, line 101, in __init__
TypeError: iteration over non-sequence

My question is how do I change my template to get this working. The template file used by the BrowserView is a close match to the original and defines a main macro. I'm pretty sure there is no problem with it as if I replace it with the following blank template I still get exactly the same error.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="plone">
<body>
<div metal:fill-slot="main">
    <tal:main-macro metal:define-macro="main">
    </tal:main-macro>
</div>
</body>
</html>

Using Products.PDBDebugMode I can debug further and find

TypeError: iteration over non-sequence
> c:\plone\parts\zope2\lib\python\zope\tales\tales.py(101)__init__()
-> self._iter = i = iter(seq)
(Pdb) a
self = <Products.PageTemplates.Expressions.PathIterator object at 0x0B2FE350>
name = vdata
seq = <Products.CMFEditions.ZVCStorageTool.ShadowHistory object at 0x0B28C370>
context = <Products.PageTemplates.Expressions.ZopeContext object at 0x0B2E3DD0>

seq here has no iter or getitem method and so iter() raises a TypeError. This error is originating from the versions_history_form.pt

<tal:block repeat="vdata history">

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦亿 2024-12-08 10:37:24

此错误与 Plone bug 中的错误不同。发生这种情况是因为您在某处有一个 tal:repeat 试图循环非序列(或其他迭代器)的内容。

This error is not the same error as the one in that Plone bug. This is happening because you have a tal:repeat somewhere that is trying to loop over something that isn't a sequence (or some other iterator).

独行侠 2024-12-08 10:37:24

抱歉,看起来这是我的代码中的错误,而不是其他错误。我正在覆盖模板,而错误源自覆盖所在的代码位 - 我没有正确同步 Plone 3.3.6 中的更改。

这个问题可能应该被删除

Sorry looks like this is a bug in my code rather than anything else. I was overriding the template and the bug was originating in the bit of code where the override was - I hadn't synchronized changes in Plone 3.3.6 correctly.

This question should probably be deleted

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文