我有以下代码来修补文件夹:
ATFolderSchema = ATContentTypeSchema.copy() + \
ConstrainTypesMixinSchema.copy() + NextPreviousAwareSchema.copy()
finalizeATCTSchema(ATFolderSchema, folderish=True, moveDiscussion=False)
field = StringField("rafal_shortdescription",
schemata = "default",
widget = StringWidget(
label = _(u"label_shortdescription",
default=u"Short Description"),
description = _(u"help_shortdescription",
default=u"Used in tabs."),
),
),
ATFolderSchema.addField(field)
和最后一行抛出:
File "/home/rafal/projects/vidensportalen_v2/eggs/Products.Archetypes-1.6.4-py2.6.egg/Products/Archetypes/Schema/__init__.py", line 198, in _validateOnAdd
raise ValueError, "Object doesn't implement IField: %r" % field
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/home/rafal/projects/vidensportalen_v2/parts/instance/etc/site.zcml", line 12.2-12.39
ZopeXMLConfigurationError: File "/home/rafal/projects/vidensportalen_v2/eggs/Plone-4.0.2-py2.6.egg/Products/CMFPlone/meta.zcml", line 39.4-43.10
ValueError: Object doesn't implement IField: <Field rafal_shortdescription(string:rw)>
知道为什么吗?
答案 0 :(得分:6)
我建议您使用archetypes.schemaextender而不是使用补丁来改变Archetypes的内容类型。
该软件包包含有关如何实现其他字段的文档。
至于你的错误,你创建了一个元素,其中包含一个元素:
>>> example = 1,
>>> print example
(1,)
删除尾随逗号,您的代码应按预期工作。