对象未实现 IField
我有以下代码来修补文件夹:
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)>
知道为什么吗?
I have following piece of code to patch the Folder:
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)
and last line throws:
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)>
Any idea why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您使用 archetypes.schemaextender 而不是使用补丁来更改 Archetypes 内容类型。
该软件包包含有关如何实现附加字段的文档。
至于您的错误,您创建了一个包含一个元素、一个字段的元组:
删除尾随逗号,您的代码应该按预期工作。
I'd advise you to use archetypes.schemaextender instead of using patches to alter Archetypes content types.
The package includes documentation on how to implement your additional field.
As for your error, you created a tuple with one element, a field:
Delete the trailing comma and your code should work as intended.