我正在阅读最近的 Professional Plone 4 Development 一书,安装 Plone 4.1.2。
我已经通过 Dexterity 成功定义了内容类型,现在正在尝试为其中一种类型创建自定义视图。架构和视图定义如下:
from zope import schema
from plone.directives import form
from five import grok
from ctcc.contenttypes import CTCCTypesMessageFactory as _
class ITrial(form.Schema):
"""A clinical trial."""
title = schema.TextLine(
title = _(u'label_title', default=u'Title'),
required = True,
)
description = schema.Text(
title=_(u'label_description', default=u'Description'),
description = _(u'help_description', default=u'A short summary of the content'),
required = False,
missing_value = u'',
)
class View(grok.View):
grok.context(ITrial)
grok.require('zope2.View')
grok.name('view')
这是类型的 FTI 中的相关部分:查看 False
<alias from="(Default)" to="(selected layout)"/>
<alias from="edit" to="@@edit"/>
<alias from="sharing" to="@@sharing"/>
<alias from="view" to="@@view"/>
<action title="View" action_id="view" category="object" condition_expr=""
url_expr="string:${folder_url}/" visible="True">
<permission value="View"/>
</action>
而模板本身,位于ctcc.contenttypes/trial_templates/view.pt中,应该只显示标题和描述:
<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="ctcc.contenttypes">
<body>
<metal:content-core fill-slot="content-core">
<metal:content-core define-macro="content-core">
<div tal:replace="structure context/text/output" />
</metal:content-core>
</metal:content-core>
</body>
</html>
在所有这些都到位的情况下访问该类型的任何实例会导致“找不到页面”错误。似乎并没有将新视图与预期路径捆绑在一起,但由于这是我使用 Plone 的第一周,我不知道从哪里开始追踪它。我也没有看到在前台模式下运行站点时出现错误。
任何帮助将不胜感激。