1

我为自定义敏捷内容类型创建了一个导入器。它可以很好地导入类型,但是当我尝试查看新导入的内容时出现“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')

有趣的是,访问内容类型的 url,后跟 /edit 工作,保存更改后,视图工作。

4

1 回答 1

3

LocationError 消息的“输出”部分表明它在呈现 RichText 字段时遇到了问题。您是否可以使用 RichTextValue 以外的内容初始化 RichText 字段?

您不能只将字符串分配给 RichText 字段。它需要一个 RichTextValue:

from plone.app.textfield.value import RichTextValue
context.body = RichTextValue(u"Your text here, in HTML")

有关详细信息,请参阅RichTextValue 上的 Dexterity 开发人员手册部分。它允许您设置输入和输出 mime 类型以及文本。

于 2013-08-19T21:37:54.057 回答