对象未实现 IField

发布于 2024-11-09 21:04:32 字数 1308 浏览 3 评论 0原文

我有以下代码来修补文件夹:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命硬 2024-11-16 21:04:32

我建议您使用 archetypes.schemaextender 而不是使用补丁来更改 Archetypes 内容类型。

该软件包包含有关如何实现附加字段的文档。

至于您的错误,您创建了一个包含一个元素、一个字段的元组:

>>> example = 1,
>>> print example
(1,)

删除尾随逗号,您的代码应该按预期工作。

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:

>>> example = 1,
>>> print example
(1,)

Delete the trailing comma and your code should work as intended.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文