我为自定义敏捷内容类型创建了一个导入程序。它导入的类型很好,但是当我尝试查看新导入的内容时,我得到'LocationError',我得到以下回溯:
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 grokcore.view.components, line 140, in __call__
Module grokcore.view.components, line 144, in _render_template
Module five.grok.components, line 130, in render
Module zope.pagetemplate.pagetemplate, line 132, in pt_render
Module zope.pagetemplate.pagetemplate, line 240, in __call__
Module zope.tal.talinterpreter, line 271, in __call__
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 888, in do_useMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 954, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 858, in do_defineMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 954, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 954, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 946, in do_defineSlot
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 858, in do_defineMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
Module Products.PageTemplates.Expressions, line 218, in evaluateStructure
Module zope.tales.tales, line 696, in evaluate
- URL: /home/action/workspace/zeocluster/src/collective.nonprofitprogrammes/collective/nonprofitprogrammes/programme_templates/programmeview.pt
- Line 20, Column 8
- Expression: <PathExpr standard:u'context/background/output'>
- Names:
{'args': (),
'container': <Programme at /Plone2/my-content/dry-forest-conservation-programme>,
'context': <Programme at /Plone2/my-content/dry-forest-conservation-programme>,
'default': <object object at 0x7f60dda304e0>,
'here': <Programme at /Plone2/my-content/dry-forest-conservation-programme>,
'loop': {},
'nothing': None,
'options': {},
'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x7f60cc0673c0>,
'request': <HTTPRequest, URL=http://mybox-23772.use1.actionbox.io:8080/Plone2/my-content/dry-forest-conservation-programme/programmeview>,
'root': <Application at >,
'static': <Products.Five.metaclass.DirectoryResource12 object at 0x7f60cc073ed0>,
'template': <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x8ee7550>,
'traverse_subpath': [],
'user': <PropertiedUser 'admin'>,
'view': <collective.nonprofitprogrammes.programme.ProgrammeView object at 0x7f60cc073bd0>,
'views': <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7f60cc073c10>}
Module zope.tales.expressions, line 217, in __call__
Module Products.PageTemplates.Expressions, line 147, in _eval
Module zope.tales.expressions, line 124, in _eval
Module Products.PageTemplates.Expressions, line 97, in trustedBoboAwareZopeTraverse
Module zope.traversing.adapters, line 136, in traversePathElement
- __traceback_info__: (u'Jam...ation.\n', 'output', [])
LocationError: (u'Jam...ation.\n', 'output')
有趣的是,访问内容类型的网址后跟/编辑工作,保存更改后视图可以正常工作。
答案 0 :(得分:3)
LocationError消息的“输出”部分表明它在呈现RichText字段时遇到问题。是否有可能使用RichTextValue之外的其他内容初始化RichText字段?
您不能只将字符串分配给RichText字段。它需要RichTextValue:
from plone.app.textfield.value import RichTextValue
context.body = RichTextValue(u"Your text here, in HTML")
有关详细信息,请参阅Dexterity Developer's Manual section on RichTextValue。它允许您设置输入和输出mime类型以及文本。