Plone:敏捷模型驱动的内容类型,带有collective.z3cform.datagridfield-将xml模型嵌套在xml模型中
我想创建一个使用collective.z3cform.datagridfield的内容类型。我一直在尝试遵循本演示中提到的示例: 该示例演示如何从主模式引用第二个模式。这是我的尝试Plone:敏捷模型驱动的内容类型,带有collective.z3cform.datagridfield-将xml模型嵌套在xml模型中,plone,dexterity,Plone,Dexterity,我想创建一个使用collective.z3cform.datagridfield的内容类型。我一直在尝试遵循本演示中提到的示例: 该示例演示如何从主模式引用第二个模式。这是我的尝试 <?xml version="1.0" ?> <model xmlns="http://namespaces.plone.org/supermodel/schema" xmlns:form="http://namespaces.plone.org/supermodel/form"&g
<?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>
然后在models/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>
supermodelparserror:'module'对象没有属性'mytype'
mypackage.mytype.IPhoneSchema
实际上,这两个模型xml文件都是在mytype.py文件中定义的。这导致运行时出现问题,mytype.py无法调用。。。mytype.IPhoneSchema
解决方案是创建一个独立于mytype.py的phoneschema.py文件,其中包含以下内容:
来自plone.supermodel导入模型
IPhoneSchema类(model.Schema):
我们现在可以调用phoneschema.IPhoneSchema,而不是调用mytype.IPhoneSchema。我可以在models/mytype.xml中包含电话模式(请参见下面的示例)
。。。
SupermodelParseError: 'module' object has no attribute 'mytype'
<schema>mypackage.mytype.IPhoneSchema</schema>
"""Schema for dict rows used in DataGridFields
they are used for individual phone numbers
"""
model.load("models/phone.xml")
<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>
...
├── __init__.py
├── configure.zcml
├── mytype.py
├── mytype_templates
│ └── view.pt
├── models
│ ├── mytype.xml
│ └── phone.xml
├── *phoneschema.py
...