【发布时间】:2013-08-05 18:41:39
【问题描述】:
我使用站点设置中的敏捷管理器创建了一个新的内容类型。我能够通过 Plone 用户界面成功添加内容,但我已经到了需要使用 python 脚本创建相同对象的地步。
我的第一次尝试是使用 invokeFactory:
context.invokeFactory("mycontenttype", id="test", Title="Test")
同样的代码适用于“文件夹”对象,但我的敏捷类型失败:
Traceback (innermost last):
Module ZPublisher.Publish, line 60, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Products.PloneHotfix20130618.spamProtect, line 35, in _patched_bindAndExec
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 344, in _exec
Module script, line 7, in test
- <PythonScript at /three-year-plan/test>
- Line 7
TypeError: invokeFactory() takes at least 3 arguments (2 given)
经过一番搜索,我找到了几个地方引用了以下函数:
from plone.dexterity.utils import createContentInContainer
任何尝试在我的 python 脚本中从 plone.dexterity.utils 导入都会导致权限错误:
Traceback (innermost last):
Module ZPublisher.Publish, line 60, in publish
Module ZPublisher.mapply, line 77, in mapply
zModule ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Products.PloneHotfix20130618.spamProtect, line 35, in _patched_bindAndExec
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 344, in _exec
Module script, line 1, in test
- <PythonScript at /my-site/test>
- Line 1
Module AccessControl.ZopeGuards, line 305, in guarded_import
Unauthorized: import of 'plone.dexterity.utils' is unauthorized
对于解决上述错误或替代方法的任何帮助将不胜感激。版本详细信息发布在下面以供参考。
版本概览
Plone 4.3.1 (4306)
CMF 2.2.7
Zope 2.13.19
Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3]
PIL 1.7.8 (Pillow)
Dexterity Content Types 2.0.8
【问题讨论】: