2011-10-28 16 views
1

我正在通过最近的Plone 4.1.2安装的Professional Plone 4 Development书籍。为敏捷类型添加新视图导致“页面未找到”查看项目

我已经通过敏捷成功定义了内容类型,现在正在尝试为其中一种类型创建自定义视图。架构&视图被定义为这样的:

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的相关章节: 视图 假

<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交流,我不知道该从哪里开始追踪。我看到在前台模式下运行网站也没有错误。

任何帮助将不胜感激。

+0

是否知道在更改GenericSetup XML中的某些内容后,您应该重新运行portal_setup中的相应步骤? –

+0

转到ZMI中的error_log,并从忽略的异常列表中删除NotFound。然后再次进入视图,看看你是否有更多的信息。 –

+0

@JC品牌:在这个阶段,我不会修改任何GenericSetup文件。灵巧类型已经创建并且工作正常,只是在python文件中添加视图后才开始给出错误。 不过,我真的应该让这个更清楚,现在就会更新。 –

回答

0

问题是这一行的模板:

<div tal:replace="structure context/text/output" /> 

我剥开一个例子模板,我认为是最低限度。感谢David格里克的建议,我删除NOTFOUND从被忽略的例外列表中的error_log,看到以下内容:

Module Products.PageTemplates.Expressions, line 225, in evaluateText 
    Module zope.tales.tales, line 696, in evaluate 
    - URL: /opt/plone41/zeocluster/src/ctcc.contenttypes/ctcc/contenttypes/trial_templates/view.pt 
    - Line 13, Column 8 
    - Expression: <PathExpr standard:u'context/text/output'> 
    [...] 
    Module OFS.Traversable, line 299, in unrestrictedTraverse 
    - __traceback_info__: ([], 'text') 
NotFound: text 

现在,我可以看到什么导致这个问题,并开始阅读深入,技援贷款,我可以看出为什么它是失败的:我怀疑是代表我的无知。

谢谢大家!

2

您是否在setup.py中包含了依赖项?

install_requires=[ 
    'setuptools', 
    'plone.app.dexterity', 
    ... 
    ], 

你是否在你的configure.zcml中初始化了Grok?

<configure 
    xmlns="http://namespaces.zope.org/zope" 
    ... 
    xmlns:grok="http://namespaces.zope.org/grok"> 

    <includeDependencies package="." /> 
    <grok:grok package="." /> 
    ... 

</configure> 

您是否在您的metadata.xml中包含了敏捷的GenericSetup配置文件?

<metadata> 
<version>1</version> 
<dependencies> 
    <dependency>profile-plone.app.dexterity:default</dependency> 
</dependencies> 
</metadata> 
+0

所有这些都是指定的,虽然我的setup.py有'plone.app.dexterity [grok]'代替。我应该在问题中指定基本类型创建功能工作正常,只有那些失败类型的自定义视图。无论如何,谢谢你的帮助。 –

相关问题