Question

I'm working through the recent Professional Plone 4 Development book, on a Plone 4.1.2 install.

I have successfully defined the content types via Dexterity and am now trying to create a custom view for one of the types. The schema & view are defined as such:

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')

Here is the relevant section from the type's FTI: view 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>

And the template itself, located in ctcc.contenttypes/trial_templates/view.pt, which should simply display the title & description:

<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>

Accessing any instances of the type with all this in place causes a "page not found" error. Something doesn't seem to be tying up the new view to the expected path, but as this is my first week with Plone I've no idea where to begin to track this down. I'm seeing no errors running the site in foreground mode either.

Any help whatsoever would be greatly appreciated.

Was it helpful?

Solution 2

The problem was with this line in the template:

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

I had stripped back an example template to what I thought was the bare minimum. Thanks to David Glick's suggestion, I removed NotFound from the ignored exceptions list in error_log and saw the following:

  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

Now that I can see what's causing the problem and have started reading deeper into TALs, I can see why it's failing: ignorance on my behalf, as suspected.

Thanks, everyone!

OTHER TIPS

did you included the dependency in setup.py?

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

did you initialized Grok in your configure.zcml?

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

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

</configure>

did you included Dexterity's GenericSetup profile in your metadata.xml?

<metadata>
 <version>1</version>
 <dependencies>
  <dependency>profile-plone.app.dexterity:default</dependency>
 </dependencies>
</metadata>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top