11---
22myst :
33 html_meta :
4- " description " : " "
5- " property=og:description " : " "
6- " property=og:title " : " "
7- " keywords " : " "
4+ " description " : " Reference for Dexterity's XML name spaces for content types in Plone "
5+ " property=og:description " : " Reference for Dexterity's XML name spaces for content types in Plone "
6+ " property=og:title " : " Reference for Dexterity's XML name spaces for content types in Plone "
7+ " keywords " : " Plone, reference, content types, Dexterity, XML, name spaces "
88---
99
1010# Dexterity XML
1111
12- ** A reference for Dexterity's XML name spaces**
12+ This chapter serves as a reference for Dexterity's XML name spaces.
13+
1314
1415## Introduction
1516
16- The schema (structure) of a Dexterity content type may be detailed in two very different ways:
17+ The schema of a Dexterity content type may be detailed in two very different ways.
1718
18- > - In Python as a Zope schema; or,
19- > - In XML
19+ - In Python as a Zope schema
20+ - In XML
2021
21- When you are using Dexterity's through-the-web schema editor, all your work is being saved in the content type's Factory Type Information (FTI) as XML.
22- ` plone.supermodel ` dynamically translates that XML into Python objects which are used to display and edit your content objects.
22+ When you use Dexterity's through-the-web (TTW) schema editor, all your work is being saved in the content type's Factory Type Information (FTI) as XML.
23+ ` plone.supermodel ` dynamically translates that XML into Python objects, which are used to display and edit your content objects.
2324
2425The XML model of your content object may be exported from Dexterity and incorporated into a Python package.
25- That's typically done with code like:
26+ That's typically done with code such as the following.
2627
2728``` python
2829class IExampleType (form .Schema ):
@@ -32,7 +33,7 @@ class IExampleType(form.Schema):
3233
3334or:
3435
35- ```
36+ ``` python
3637from plone.supermodel import xmlSchema
3738
3839IExampleType = xmlSchema(" models/example_type.xml" )
@@ -43,10 +44,11 @@ XML models in a package may be directly edited.
4344This document is a reference to the tags and attributes you may use in model XML files.
4445This includes several form-control and security-control attributes that are not available through the TTW schema editor.
4546
46- ## XML Document Structure
47+
48+ ## XML document structure
4749
4850Dexterity requires that its model XML be well-formed XML, including name space declarations.
49- The typical structure of a Dexterity XML document is:
51+ The typical structure of a Dexterity XML document is the following.
5052
5153``` xml
5254<?xml version =" 1.0" encoding =" UTF-8" ?>
@@ -63,12 +65,13 @@ The typical structure of a Dexterity XML document is:
6365</model >
6466```
6567
66- Only the default name space (.../ supermodel/schema) is required for basic schema.
68+ Only the default name space ` supermodel/schema ` is required for basic schema.
6769The ` supermodel/form ` and ` supermodel/schema ` provide additional attributes to control form presentation and security.
6870
69- ## supermodel/schema fields
7071
71- Most of the supermodel/schema field tag and its attributes map directly to what's available via the TTW schema editor:
72+ ## ` supermodel/schema ` fields
73+
74+ Most of the ` supermodel/schema ` field tag and its attributes map directly to what's available via the TTW schema editor:
7275
7376``` xml
7477<field name =" dummy" type =" zope.schema.TextLine" >
@@ -83,11 +86,12 @@ Most of the supermodel/schema field tag and its attributes map directly to what'
8386</field >
8487```
8588
86- The field ` type ` needs to be the full dotted name (as if it was being imported in Python) of the field type.
89+ The field ` type ` needs to be the full dotted name of the field type, as if it were imported in Python.
90+
8791
8892### Fieldsets
8993
90- It's easy to add fieldsets by surrounding embedding fields tags in a ` fieldset ` block:
94+ To add fieldsets, surround embedded ` field ` tags in a ` fieldset ` block.
9195
9296``` xml
9397<schema >
@@ -108,9 +112,10 @@ It's easy to add fieldsets by surrounding embedding fields tags in a `fieldset`
108112</schema >
109113```
110114
115+
111116### Vocabularies
112117
113- Vocabularies may be specified via dotted names using the ` source ` tag:
118+ Vocabularies may be specified via dotted names using the ` source ` tag.
114119
115120``` xml
116121<field name =" dummy" type =" zope.schema.Choice" >
@@ -124,15 +129,15 @@ Vocabularies may be specified via dotted names using the `source` tag:
124129</field >
125130```
126131
127- Where the full Python dotted-name of a Zope vocabulary in a package:
132+ Where the full Python dotted-name of a Zope vocabulary in a package.
128133
129- ```
134+ ``` python
130135from zope.schema.vocabulary import SimpleVocabulary
131136
132- dummy_vocabulary_instance = SimpleVocabulary.fromItems([(1, 'a' ), (2, 'c' )])
137+ dummy_vocabulary_instance = SimpleVocabulary.fromItems([(1 , " a " ), (2 , " c " )])
133138```
134139
135- Or, a source binder:
140+ Or, a source binder.
136141
137142``` xml
138143<field name =" dummy" type =" zope.schema.Choice" >
@@ -141,7 +146,7 @@ Or, a source binder:
141146</field >
142147```
143148
144- With Python like:
149+ Or in Python.
145150
146151``` python
147152from zope.schema.interfaces import IContextSourceBinder
@@ -150,20 +155,20 @@ class Binder(object):
150155 implements(IContextSourceBinder)
151156
152157 def __call__ (self , context ):
153- return SimpleVocabulary.fromValues([' a ' , ' d ' , ' f ' ])
158+ return SimpleVocabulary.fromValues([" a " , " d " , " f " ])
154159
155160dummy_binder = Binder()
156161```
157162
158163You may also use the ` vocabulary ` tag rather than ` source ` to refer to named vocabularies registered via the ZCA.
159164
165+
160166### Internationalization
161167
162- Translation domains and message ids can be specified for text
163- that is interpreted as unicode. This will result in deserialization
164- as a zope.i18nmessageid message id rather than a basic Unicode string.
168+ Translation domains and message IDs can be specified for text that is interpreted as Unicode.
169+ This will result in deserialization as a ` zope.i18nmessageid ` message ID rather than a basic Unicode string.
165170
166- Note that we need to add the i18n namespace and a domain specification:
171+ Note that we need to add the ` i18n ` namespace and a domain specification.
167172
168173``` xml
169174<model xmlns =" http://namespaces.plone.org/supermodel/schema"
@@ -179,21 +184,20 @@ Note that we need to add the i18n namespace and a domain specification:
179184</model >
180185```
181186
182- ## supermodel/form attributes
183187
184- supermodel/form provides attributes that govern presentation and editing.
188+ ## ` supermodel/form ` attributes
185189
186- ### after/before
190+ ` supermodel/form ` provides attributes that govern presentation and editing.
187191
188- To re-order fields, use ` form:after ` or ` form:before ` .
189192
190- The value should be either ` '*' ` , to put the field first/last in the form,
191- or the name of a another field. Use ` '.fieldname' ` to refer to field in the
192- current schema (or a base schema). Use a fully prefixed name (e.g.
193- ` 'my.package.ISomeSchema' ` ) to refer to a field in another schema. Use an
194- unprefixed name to refer to a field in the default schema for the form.
193+ ### ` after/before `
195194
196- Example:
195+ To reorder fields, use ` form:after ` or ` form:before ` .
196+
197+ The value should be either ` "*" ` , to put the field first/last in the form, or the name of a another field.
198+ Use ` ".fieldname" ` to refer to a field in the current schema or a base schema.
199+ Use a fully prefixed name (for example, ` "my.package.ISomeSchema" ` ) to refer to a field in another schema.
200+ Use an unprefixed name to refer to a field in the default schema of the form.
197201
198202``` xml
199203<field type =" zope.schema.TextLine"
@@ -203,13 +207,11 @@ Example:
203207</field >
204208```
205209
206- ### mode
207210
208- To turn a field into a view mode or hidden field, use ` form:mode ` . The
209- mode may be set for only some forms by specifying a form interface in the
210- same manner as for ` form:omitted ` .
211+ ### ` mode `
211212
212- Example:
213+ To turn a field into a view mode or hidden field, use ` form:mode ` .
214+ The mode may be set for only some forms by specifying a form interface in the same manner as for ` form:omitted ` .
213215
214216``` xml
215217<field type =" zope.schema.TextLine"
@@ -219,14 +221,12 @@ Example:
219221</field >
220222```
221223
222- ### omitted
223224
224- To omit a field from all forms, use ` form:omitted="true" ` . To omit a field
225- only from some forms, specify a form interface like
226- ` form:omitted="z3c.form.interfaces.IForm:true" ` . Multiple interface: value
227- settings may be specified, separated by spaces.
225+ ### ` omitted `
228226
229- Examples:
227+ To omit a field from all forms, use ` form:omitted="true" ` .
228+ To omit a field only from some forms, specify a form interface such as ` form:omitted="z3c.form.interfaces.IForm:true" ` .
229+ Multiple ` interface:value ` settings may be specified, separated by spaces.
230230
231231``` xml
232232<field type =" zope.schema.TextLine"
@@ -244,12 +244,10 @@ Examples:
244244
245245The latter example hides the field on everything except the edit form.
246246
247- ### widget
248247
249- To set a custom widget for a field, use ` form:widget ` to give a fully
250- qualified name to the field widget factory.
248+ ### ` widget `
251249
252- Example:
250+ To set a custom widget for a field, use ` form:widget ` to give a fully qualified name to the field widget factory.
253251
254252``` xml
255253<field type =" zope.schema.TextLine"
@@ -259,14 +257,11 @@ Example:
259257</field >
260258```
261259
262- ### Dynamic Defaults
263260
264- To set a dynamic default for a field, use a ` defaultFactory ` tag to
265- give a fully qualified name for a callable. The defaultFactory callable must
266- provide either plone.supermodel.interfaces.IDefaultFactory or
267- zope.schema.interfaces.IContextAwareDefaultFactory.
261+ ### Dynamic defaults
268262
269- Example:
263+ To set a dynamic default for a field, use a ` defaultFactory ` tag to give a fully qualified name for a callable.
264+ The defaultFactory callable must provide either ` plone.supermodel.interfaces.IDefaultFactory ` or ` zope.schema.interfaces.IContextAwareDefaultFactory ` .
270265
271266``` xml
272267<field type =" zope.schema.TextLine" name =" three" >
@@ -275,34 +270,31 @@ Example:
275270</field >
276271```
277272
278- Sample Python for the validator factory:
273+ Sample Python for the validator factory.
279274
280275``` python
281276@provider (IDefaultFactory)
282277def dummy_defaultFactory ():
283- return ' something'
278+ return " something"
284279```
285280
286- For a callable using context:
281+ For a callable using context.
287282
288283``` python
289284@provider (IContextAwareDefaultFactory)
290285def dummy_defaultCAFactory (context ):
291286 return context.something
292287```
293288
294- :::{note}
295- The ` defaultFactory ` tag was added in plone.supermodel 1.2.3,
296- shipping with Plone 4.3.2+.
297- :::
289+ ``` {versionadded} 4.3.2
290+ The `defaultFactory` tag was added in `plone.supermodel` 1.2.3, shipping with Plone 4.3.2 and later.
291+ ```
298292
299- ### validator
300293
301- To set a custom validator for a field, use ` form:validator ` to give a fully
302- qualified name to the field validator factory. The validator factory should be
303- a class derived from one of the validators in z3c.form.validator.
294+ ### ` validator `
304295
305- Example:
296+ To set a custom validator for a field, use ` form:validator ` to give a fully qualified name to the field validator factory.
297+ The validator factory should be a class derived from one of the validators in ` z3c.form.validator ` .
306298
307299``` xml
308300<field type =" zope.schema.TextLine"
@@ -312,7 +304,7 @@ Example:
312304</field >
313305```
314306
315- Sample Python for the validator factory:
307+ Sample Python for the validator factory.
316308
317309``` python
318310class TestValidator (z3c .form .validator .SimpleFieldValidator ):
@@ -322,17 +314,16 @@ class TestValidator(z3c.form.validator.SimpleFieldValidator):
322314 raise Invalid(" Test" )
323315```
324316
317+
325318(dexterity-xml-security)=
326319
327- ## supermodel/security attributes
320+ ## ` supermodel/security ` attributes
328321
329- ### read-permission/write-permission
330322
331- To set a read or write permission, use ` security:read-permission ` or
332- ` security:write-permission ` . The value should be the name of an
333- ` IPermission ` utility.
323+ ### ` read-permission ` and ` write-permission `
334324
335- Example:
325+ To set a read or write permission, use ` security:read-permission ` or ` security:write-permission ` .
326+ The value should be the name of an ` IPermission ` utility.
336327
337328``` xml
338329<field type =" zope.schema.TextLine"
0 commit comments