Skip to content

Commit d871fa8

Browse files
committed
revise dexterity
1 parent 8700a71 commit d871fa8

1 file changed

Lines changed: 63 additions & 43 deletions

File tree

docs/mastering-plone/dexterity.md

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,27 @@ myst:
1111

1212
# Content types I
1313

14+
```{card}
1415
In this part you will:
1516
1617
- Learn about content types
1718
- Customize existing types
1819
- Create a content type through the web
19-
20+
```
2021

2122
(dexterity1-what-label)=
2223

2324
## What is a content type?
2425

25-
A content type instance is a kind of object that can store information and is editable by users.
26+
A content type is a kind of object that can store information and is editable by users.
2627
We have different content types to reflect the different kinds of information about which we need to collect and display information.
2728

2829
Pages, events, news items, files (binary) and images are all content types.
2930

30-
See "Features of Plone – {ref}`features-content-types-label`" for an overview.
31+
```{seealso}
32+
33+
See {ref}`features-content-types-label` for an overview of Plone's built-in content types.
34+
```
3135

3236
It is common in developing a web site that you'll need customized versions of common content types, or perhaps even entirely new types.
3337

@@ -46,28 +50,29 @@ Every Plone content type has the following parts:
4650

4751
Schema
4852

49-
: A definition of fields that comprise a content type, properties of an object.
53+
: A definition of fields that can be stored and edited for a content item with this type.
5054

51-
FTI
55+
Factory Type Information (FTI)
5256

53-
: The "Factory Type Information" configures the content type in Plone, assigns it a name, additional features and available views to it.
57+
: The "Factory Type Information" is a specification stored in the `portal_types` tool which configures the content type in Plone, assigns it a name, additional features and available views to it.
5458

5559
Views
5660

5761
: A view is a representation of the object and the content of its fields that may be rendered in response to a request.
5862
You may have _one or more_ views for an object.
59-
Some may be _visual_ — intended for display as web pages — others may be intended to satisfy AJAX requests and render content in formats like JSON or XML.
63+
Some may be _visual_, intended for display as web pages.
64+
Others may be intended to satisfy AJAX requests and render content in formats like JSON or XML.
6065

6166
## Schemas, Fields and Values
6267

6368
In a schema you can model fields that are used to store data.
64-
Plone automatically creates forms bases on the schemata of a content type to add and edit content.
69+
Plone automatically creates forms to add and edit content based on the schemas of a content type.
6570

6671
Values of these fields are attributes on content objects.
6772

68-
Here is a example that shows how to access and modify these values in python:
73+
Here is a example that shows how to access and modify these values in Python:
6974

70-
```pycon
75+
```python
7176
>>> obj.title
7277
'A Newsitem'
7378
>>> obj.description
@@ -83,25 +88,33 @@ b'\x89PNG\r\n\x1a\n\x00\x00\x00\...'
8388

8489
## Behaviors
8590

86-
Content types can have additional schemata. These are called behaviors.
91+
Content types can have additional schemas.
92+
These are called behaviors.
8793
They are meant to be used across content types to add shared functionality.
8894

8995
One example is the ability of most content types to allow them to be excluded from the navigation.
9096
The field is available on all types even though it is not defined in their schema.
9197
Instead it is provided by the behavior `plone.excludefromnavigation` that most content types use.
9298

93-
Each behavior schema can define fields. The values of these fields are again attributes on content objects.
99+
Each behavior schema can define fields.
100+
The values of these fields are again attributes on content objects.
101+
102+
The behavior `plone.excludefromnavigation` adds a field `exclude_from_nav` to each object.
103+
The value is either `True` or `False` because it is a boolean field.
94104

95-
The behavior `plone.excludefromnavigation` adds a attribute `exclude_from_nav` to each object. The value is either `True` or `False` because it is a boolean field.
96105

97106
(dexterity1-modify-label)=
98107

99-
## Modifying existing types
108+
## Modify an existing content type schema
100109

101110
For now, we will not code anything.
102111
We will only use the Plone web interface features.
103112

104-
- Go to the {guilabel}`Content Types` control panel at http://localhost:3000/controlpanel/dexterity-types.
113+
- Go to the {guilabel}`Content Types` control panel at <http://localhost:3000/controlpanel/dexterity-types>.
114+
115+
```{note}
116+
"Dexterity" is the internal name of Plone's content type system.
117+
```
105118

106119
- Inspect some of the existing default types.
107120

@@ -148,32 +161,40 @@ We will only use the Plone web interface features.
148161

149162
(dexterity1-create-ttw-label)=
150163

151-
## Creating content types TTW
164+
## Create a content type through the web
165+
166+
In this step we will create a content type called `Talk` and try it out.
167+
When it's ready, we will move the code from the web to the filesystem and into our own add-on.
168+
Later we will extend that content type.
169+
170+
- Go to the {guilabel}`Content Types` control panel: <http://localhost:3000/controlpanel/dexterity-types>.
171+
- Use the add button at upper left to add a new content type "Talk".
172+
- Edit the schema of the Talk content type and add some fields to it:
152173

153-
In this step we will create a content type called `Talk` and try it out. When it's ready we will move the code from the web to the file system and into our own add-on. Later we will extend that content type.
174+
- **Type of talk**, type "Choice". Add possible values: Talk, Training, Keynote.
175+
- **Details**, type "Rich Text" with a maximum length of 2000.
176+
- **Audience**, type "Multiple Choice". Add possible values: Beginner, Advanced, Professional.
154177

155-
- Add new content type "Talk" and some fields for it:
178+
- Save the schema.
156179

157-
- {guilabel}`Add new field` "Type of talk", type "Choice". Add options: talk, keynote, training.
158-
- {guilabel}`Add new field` "Details", type "Rich Text" with a maximal length of 2000.
159-
- {guilabel}`Add new field` "Audience", type "Multiple Choice". Add options: beginner, advanced, pro.
160-
- Check the behaviors that are enabled: _Dublin Core metadata_, _Name from title_. Do we need them all?
180+
- Check the behaviors that are enabled: _Dublin Core metadata_, _Name from title_. Do we need them all?
161181

162182
- Test the content type.
163183

164-
- Return to the control panel <http://localhost:8080/Plone/@@dexterity-types>
184+
- Return to the control panel: <http://localhost:3000/controlpanel/dexterity-types>.
165185

166-
- Extend the new type: add the following fields:
186+
- Extend the new type by adding the following fields:
167187

168-
- "Speaker", type: "Text line"
169-
- "Email", type: "Email"
170-
- "Image", type: "Image", not required
171-
- "Speaker Biography", type: "Rich Text"
188+
- **Speaker**, type: "Text line"
189+
- **Email**, type: "Email"
190+
- **Image**, type: "Image", not required
191+
- **Speaker Biography**, type: "Rich Text"
172192

173193
- Test again.
174194

175195
````{note}
176-
The schema you created through the web is stored as XML in the database. Here is the complete XML schema created by our actions:
196+
The schema you created through the web is stored as XML in the database.
197+
Here is the complete XML schema created by our actions:
177198
178199
```{code-block} xml
179200
:linenos:
@@ -215,7 +236,7 @@ The schema you created through the web is stored as XML in the database. Here is
215236
<title>Speaker</title>
216237
</field>
217238
<field name="email" type="plone.schema.email.Email">
218-
<description>Adress of the speaker</description>
239+
<description>Email of the speaker</description>
219240
<title>Email</title>
220241
</field>
221242
<field name="image" type="plone.namedfile.field.NamedBlobImage">
@@ -234,7 +255,8 @@ The schema you created through the web is stored as XML in the database. Here is
234255
```
235256
````
236257

237-
It's awesome that we can do so much through the web and great for prototyping or small projects. But it's also a dead end if we want to reuse this content type in other sites.
258+
It's awesome that we can do so much through the web and great for prototyping or small projects.
259+
But it's also a dead end if we want to reuse this content type in other sites.
238260

239261
Also, for professional development, we want to be able to use version control for our work, and we'll want to be able to add the kind of business logic that will require programming.
240262

@@ -247,26 +269,24 @@ Using Python to define the schema gives us much more control (e.g. for validatio
247269

248270
### Exercise 1
249271

250-
Modify Pages to allow uploading an image as decoration (like News Items do).
272+
Modify the Page content type to allow uploading an image as decoration (like News Items do).
251273

252274
```{dropdown} Solution
253275
:animate: fade-in-slide-down
254276
:icon: question
255277
256-
- Go to the dexterity control panel (<http://localhost:8080/Plone/@@dexterity-types>)
257-
- Click on *Page* (<http://127.0.0.1:8080/Plone/dexterity-types/Document>)
258-
- Select the tab *Behaviors* (<http://127.0.0.1:8080/Plone/dexterity-types/Document/@@behaviors>)
278+
- Go to the Content Types control panel (<http://localhost:3000/controlpanel/dexterity-types>)
279+
- Click on *Page* (<http://localhost:3000/controlpanel/dexterity-types/Document>)
280+
- Select the tab *Behaviors*
259281
- Check the box next to {guilabel}`Lead Image` and save.
260282
261283
The images are displayed above the title.
262284
```
263285

264286
## Further reading
265-
- Documentation {doc}`plone6docs:backend/fields`
266-
- [Example content type](https://github.com/collective/example.contenttype) A Plone content type with all available fields
267-
268-
Plone 5 documentation
269-
- [Dexterity Developer Manual](https://5.docs.plone.org/external/plone.app.dexterity/docs/index.html)
270-
- [The standard behaviors](https://5.docs.plone.org/external/plone.app.dexterity/docs/reference/standard-behaviours.html)
271-
- [Dexterity XML](https://5.docs.plone.org/external/plone.app.dexterity/docs/reference/dexterity-xml.html)
272-
- [Model-driven types](https://5.docs.plone.org/external/plone.app.dexterity/docs/model-driven-types.html#model-driven-types)
287+
- Plone documentation about
288+
- {doc}`plone6docs:backend/content-types/index`
289+
- {doc}`plone6docs:backend/schemas`
290+
- {doc}`plone6docs:backend/fields`
291+
- {doc}`plone6docs:backend/behaviors`
292+
- [Example content type](https://github.com/collective/example.contenttype) - A Plone content type with all available fields

0 commit comments

Comments
 (0)