我想創建一個使用collective.z3cform.datagridfield的內容類型。我一直在嘗試遵循本演示中提到的示例: http://glicksoftware.com/presentations/dexterity-in-the-wildPlone:敏捷模型驅動的內容類型與collective.z3cform.datagridfield - 在xml模型中嵌套xml模型
該示例演示了從主模式引用第二個模式。這是我的嘗試。
<?xml version="1.0" ?>
<model xmlns="http://namespaces.plone.org/supermodel/schema"
xmlns:form="http://namespaces.plone.org/supermodel/form">
<field name="telephone" type="zope.schema.List"
form:widget="collective.z3cform.datagridfield.DataGridFieldFactory">
<title>Telephone</title>
<description>Enter telephone numbers here</description>
<max_length>10</max_length>
<min_length>2</min_length>
<missing_value/>
<readonly>False</readonly>
<required>False</required>
<value_type type="collective.z3cform.datagridfield.DictRow">
<title>Number</title>
<schema>mypackage.mytype.IPhoneSchema</schema>
</value_type>
</field>
</schema>
</model>
我定義我的第二個架構中mypackage中/ mytype.py看起來像這樣:
from plone.supermodel import model
class IPhoneSchema(model.Schema):
"""Schema for dict rows used in DataGridFields
name is the 'real' name
token is the token used in the vocabularies
"""
#
model.load("models/phone.xml")
然後在型號/ phone.xml我有以下幾點:
<?xml version="1.0" ?>
<model xmlns="http://namespaces.plone.org/supermodel/schema"
xmlns:form="http://namespaces.plone.org/supermodel/form">
<schema>
<field name="number" type="zope.schema.TextLine">
<description/>
<required>False</required>
<title>Number</title>
</field>
</schema>
</model>
當我啓動Plone時,出現以下錯誤:
SupermodelParseError: 'module' object has no attribute 'mytype'
<schema>mypackage.mytype.IPhoneSchema</schema>