Creating Custom Dexterity Objects from Plone API

I have a few hundred thousand JSON documents that I want to covert into custom Dexterity objects in Plone. When I create a custom Dexterity content type from scratch, I can use the API to create the object, but it only makes it an uneditable folder object. Not to be undaunted, I created a clone of the Document (Page) object and modified that with new fields. I tweaked my python script (to accommodate the new type-particulars) and tried again. The script ran properly, and the object appeared within Plone. However, when I went to view it, I got the following error:

Display traceback as text

Traceback (innermost last):

    Module ZPublisher.Publish, line 138, in publish
    Module ZPublisher.mapply, line 77, in mapply
    Module ZPublisher.Publish, line 48, in call_object
    Module Products.Five.browser.metaconfigure, line 485, in __call__
    Module Products.Five.browser.pagetemplatefile, line 125, in __call__
    Module Products.Five.browser.pagetemplatefile, line 59, in __call__
    Module zope.pagetemplate.pagetemplate, line 137, in pt_render
    Module, line 98, in __call__
    Module, line 163, in render
    Module chameleon.zpt.template, line 261, in render
    Module chameleon.template, line 191, in render
    Module chameleon.template, line 171, in render
    Module, line 246, in render
    Module, line 1223, in render_master
    Module, line 420, in render_content
    Module, line 234, in __fill_content_core
    Module, line 137, in render_content_core

AttributeError: 'str' object has no attribute 'output_relative_to'

 - Expression: "python:context.text.output_relative_to(view.context)"
 - Filename:   ... egg/plone/app/contenttypes/browser/templates/
 - Location:   (line 15: col 29)
 - Source:     ... ucture python:context.text.output_relative_to(view.context)"
 - Arguments:  repeat: {...} (0)
               template: <ViewPageTemplateFile - at 0x7ff56bb8e950>
               views: <ViewMapper - at 0x7ff56b665850>
               modules: <instance - at 0x7ff5761baa70>
               args: <tuple - at 0x7ff57e5e7050>
               here: <ImplicitAcquisitionWrapper bush-v-gore at 0x7ff56dca0320>
               user: <ImplicitAcquisitionWrapper - at 0x7ff56dca0f50>
               nothing: <NoneType - at 0x55c21fd724d0>
               container: <ImplicitAcquisitionWrapper bush-v-gore at 0x7ff56dca0320>
               request: <instance - at 0x7ff56b9d8dd0>
               wrapped_repeat: <SafeMapping - at 0x7ff56a1b8208>
               traverse_subpath: <list - at 0x7ff56b64ab48>
               default: <object - at 0x7ff57e5d0540>
               loop: {...} (0)
               context: <ImplicitAcquisitionWrapper bush-v-gore at 0x7ff56dca0320>
               view: <SimpleViewClass from /opt/plone/buildout-cache/eggs/ document_view at 0x7ff56a0d8c90>
               translate: <function translate at 0x7ff56a1a1500>
               root: <ImplicitAcquisitionWrapper Zope at 0x7ff56df5f550>
               options: {...} (0)
               target_language: <NoneType - at 0x55c21fd724d0>

Is there some trick to creating content objects via the API that I'm missing? Some tweak in kwargs that I need to include so the object is viewable and editable?

You need to add a RichTextValue as described in

text is not a simple string but a instance of


    text=RichTextValue(u'<p>Some Text</p>', 'text/html', 'text/x-html-safe'),


I've added an issue for this:

Thanks, Philip. That was indeed the problem. Incidentally, cloning a new Dexterity object from the standard Page object also solved the folder/editability problem.

That still leaves open the question of why can't a from-scratch Dexterity object be non-folderish/ediable, however. Fortunately, we have a work-around.