2

以下是我正在处理的敏捷内容类型的片段。有两种内容类型,程序和项目。应该可以将项目与程序相关联(我在下面将其定义为 RelationChoice)。

from five import grok
from plone.directives import dexterity, form

from zope import schema
from zope.schema.interfaces import IContextSourceBinder
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from zope.interface import invariant, Invalid

from z3c.form import group, field

from plone.namedfile.interfaces import IImageScaleTraversable
from plone.namedfile.field import NamedImage, NamedFile
from plone.namedfile.field import NamedBlobImage, NamedBlobFile

from plone.app.textfield import RichText

from z3c.relationfield.schema import RelationList, RelationChoice
from plone.formwidget.contenttree import ObjPathSourceBinder

from alteroo.programmeshowcase import MessageFactory as _
from alteroo.programmeshowcase.project import IProject


# Interface class; used to define content-type schema.

class IBaseProgramme(form.Schema, IImageScaleTraversable):
    """
    Programme
    """

    # If you want a schema-defined interface, delete the form.model
    # line below and delete the matching file in the models sub-directory.
    # If you want a model-based interface, edit
    # models/progamme.xml to define the content type
    # and add directives here as necessary.

    form.model("models/programme.xml")

class IProgamme(IBaseProgramme):
    """A conference program. Programs can contain Sessions.
    """

    project = RelationChoice(
        title=_(u"Project"),
        source=ObjPathSourceBinder(object_provides=IProject.__identifier__),
        required=False,
    )

上面的定义产生了一个看起来像这样的编辑视图。当我尝试添加相关项目时,它会引发错误。

在此处输入图像描述

这是我尝试添加相关项目时得到的回溯:

Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module plone.z3cform.layout, line 66, in __call__
  Module plone.z3cform.layout, line 50, in update
  Module plone.dexterity.browser.add, line 112, in update
  Module plone.z3cform.fieldsets.extensible, line 59, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 141, in update
  Module plone.app.z3cform.csrf, line 21, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 315, in __call__
  Module z3c.form.button, line 170, in __call__
  Module plone.dexterity.browser.add, line 99, in handleAdd
  Module z3c.form.form, line 247, in createAndAdd
  Module plone.dexterity.browser.add, line 78, in add
  Module plone.dexterity.utils, line 167, in addContentToContainer
  Module OFS.ObjectManager, line 358, in _setObject
  Module zope.event, line 31, in notify
  Module zope.component.event, line 24, in dispatch
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module zope.component.event, line 32, in objectEventNotify
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module five.intid.intid, line 101, in addIntIdSubscriber
  Module zope.event, line 31, in notify
  Module zope.component.event, line 24, in dispatch
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module z3c.relationfield.event, line 39, in addRelationsEventOnly
  Module z3c.relationfield.event, line 28, in addRelations
  Module z3c.relationfield.event, line 143, in _setRelation
  Module zope.component._api, line 169, in getUtility
ComponentLookupError: (<InterfaceClass zc.relation.interfaces.ICatalog>, '')
4

1 回答 1

3

您需要在插件控制面板中激活“关系字段”(plone.app.relationfield)来安装关系目录。

于 2013-07-12T16:42:22.280 回答