How to move a content type definition created TTW to the file system

105 views Asked by At

I was modeling a content type definition using the web interface on the Dexterity Types control panel configlet in order to include the resulting code in my project:

I ended up with a file like this one, that includes a RichText field:

<model
    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    xmlns:security="http://namespaces.plone.org/supermodel/security"
    xmlns:marshal="http://namespaces.plone.org/supermodel/marshal"
    xmlns:form="http://namespaces.plone.org/supermodel/form"
    xmlns:indexer="http://namespaces.plone.org/supermodel/indexer"
    xmlns="http://namespaces.plone.org/supermodel/schema">
  <schema>
    ...
    <field name="biography" type="plone.app.textfield.RichText">
      <description>A detailed description of a person's life.</description>
      <required>False</required>
      <title>Biography</title>
    </field>
    ...
  </schema>
</model>

I copied that file to a directory inside my project that I called models.

I exported also the type information and I edited the file to look like this:

<?xml version="1.0"?>
<object name="mytype" meta_type="Dexterity FTI">
  ...
  <property name="schema">my.project.content.IMyType</property>
  <property name="klass">my.project.content.MyType</property>
  ...
</object>

Then I added the following code inside my content.py module:

from plone.dexterity.content import Item
from plone.supermodel import model

class IMyType(model.Schema):

    """My Type."""

    model.load('models/mytype.xml')

class MyType(Item):

    """My Type."""

Finally, I added some basic tests but they are failing with the following error (full traceback here):

ConfigurationExecutionError: <class 'plone.supermodel.parser.SupermodelParseError'>: Field type plone.app.textfield.RichText specified for field biography is not supported

What I am doing wrong here? Did I forget something?

0

There are 0 answers