Skip to content

Commit f3ec361

Browse files
authored
Merge branch '6.0' into backend-richtextfield
2 parents ce5009d + 65fa8ba commit f3ec361

24 files changed

+609
-102
lines changed

docs/backend/fields.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,43 @@ See {ref}`backend-ploneschema-label` for more details.
323323

324324
(backend-fields-schema-label)=
325325

326-
## schema
326+
## Schema
327327

328+
With `plone.autoform` and `plone.supermodel` we can use directives to add information to the schema fields.
328329

329-
(backend-fields-schema-autoform-label)=
330330

331-
### `autoform` (directives) schema ordering, filtering, and permissions
331+
(backend-fields-schema-autoform-permission)=
332332

333+
### Protect a field with a permission
333334

334-
(backend-fields-supermodel-label)=
335+
By default, fields are included in the form regardless of the user's permissions.
336+
Fields can be protected using the `read_permission` and `write_permission` directives.
337+
The read permission is checked when the field is in display mode, and the write permission is checked when the field is in input mode.
338+
The permission should be given with its Zope 3-style name, such as `cmf.ManagePortal` instead of `Manage portal`.
335339

336-
## `supermodel` (XML)
340+
In this example, the `secret` field is protected by the `cmf.ManagePortal` permission as both a read and write permission.
341+
This means that in both display and input modes, the field will only be included in the form for users who have that permission:
337342

343+
```python
344+
from plone.supermodel import model
345+
from plone.autoform import directives as form
346+
347+
class IMySchema(model.Schema):
348+
form.read_permission(secret="cmf.ManagePortal")
349+
form.write_permission(secret="cmf.ManagePortal")
350+
secret = schema.TextLine(
351+
title = "Secret",
352+
)
353+
```
338354

339-
(backend-fields-supermodel-autoform-label)=
355+
In supermodel XML, the directives are `security:read-permission` and
356+
`security:write-permission`:
340357

341-
### `autoform` (directives) supermodel ordering, filtering, and permissions
358+
```xml
359+
<field type="zope.schema.TextLine"
360+
name="secret"
361+
security:read-permission="cmf.ManagePortal"
362+
security:write-permission="cmf.ManagePortal">
363+
<title>Secret</title>
364+
</field>
365+
```

docs/backend/schemas.md

Lines changed: 142 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,148 @@ Note this won't have behavior fields added to it at this stage, only the fields
217217
- {doc}`reference list of fields used in Plone </backend/fields>`
218218

219219

220+
(backend-schemas-directives-label)=
221+
222+
## Schema directives
223+
224+
With `plone.autoform` and `plone.supermodel`, we can use directives to add information to the schema fields.
225+
226+
227+
### Omit fields
228+
229+
A field can be omitted entirely from all forms, or from some forms, using the `omitted` and `no_omit` directives.
230+
In this example, the `dummy` field is omitted from all forms, and the `edit_only` field is omitted from all forms except those that provide the `IEditForm` interface:
231+
232+
```{code-block} python
233+
:emphasize-lines: 7,12,13
234+
:linenos:
235+
236+
from z3c.form.interfaces import IEditForm
237+
from plone.supermodel import model
238+
from plone.autoform import directives as form
239+
240+
class IMySchema(model.Schema):
241+
242+
form.omitted("dummy")
243+
dummy = schema.Text(
244+
title="Dummy"
245+
)
246+
247+
form.omitted("edit_only")
248+
form.no_omit(IEditForm, "edit_only")
249+
edit_only = schema.TextLine(
250+
title = "Only included on edit forms",
251+
)
252+
```
253+
254+
In supermodel XML, this can be specified as:
255+
256+
```{code-block} xml
257+
:emphasize-lines: 3,9
258+
259+
<field type="zope.schema.TextLine"
260+
name="dummy"
261+
form:omitted="true">
262+
<title>Dummy</title>
263+
</field>
264+
265+
<field type="zope.schema.TextLine"
266+
name="edit-only"
267+
form:omitted="z3c.form.interfaces.IForm:true z3c.form.interfaces.IEditForm:false">
268+
<title>Only included on edit form</title>
269+
</field>
270+
```
271+
272+
`form:omitted` may be either a single boolean value, or a space-separated list of `<form_interface>:<boolean>` pairs.
273+
274+
275+
### Reorder fields
276+
277+
A field's position in the form can be influenced using the `order_before` and `order_after` directives.
278+
In this example, the `not_last` field is placed before the `summary` field, even though it is defined afterward:
279+
280+
```{code-block} python
281+
:emphasize-lines: 12
282+
:linenos:
283+
284+
from plone.supermodel import model
285+
from plone.autoform import directives as form
286+
287+
class IMySchema(model.Schema):
288+
289+
summary = schema.Text(
290+
title="Summary",
291+
description="Summary of the body",
292+
readonly=True
293+
)
294+
295+
form.order_before(not_last="summary")
296+
not_last = schema.TextLine(
297+
title="Not last",
298+
)
299+
```
300+
301+
The value passed to the directive may be either `*`, indicating before or after all fields, or the name of another field.
302+
Use `.<fieldname>` to refer to the field in the current schema or a base schema.
303+
Prefix with the schema name, such as `IDublinCore.title`, to refer to a field in another schema.
304+
Use an unprefixed name to refer to a field in either the current or default schema for the form.
305+
306+
In supermodel XML, the directives are called `form:before` and `form:after`.
307+
For example:
308+
309+
```{code-block} xml
310+
:emphasize-lines: 3
311+
312+
<field type="zope.schema.TextLine"
313+
name="not_last"
314+
form:before="*">
315+
<title>Not last</title>
316+
</field>
317+
```
318+
319+
320+
### Organizing fields into fieldsets
321+
322+
Fields can be grouped into fieldsets, which will be rendered within an HTML `<fieldset>` tag.
323+
In this example the `footer` and `dummy` fields are placed within the `extra` fieldset:
324+
325+
```{code-block} python
326+
:emphasize-lines: 6-9
327+
:linenos:
328+
329+
from plone.supermodel import model
330+
from plone.autoform import directives as form
331+
332+
class IMySchema(model.Schema):
333+
334+
model.fieldset("extra",
335+
label="Extra info",
336+
fields=["footer", "dummy"]
337+
)
338+
339+
footer = schema.Text(
340+
title="Footer text",
341+
)
342+
343+
dummy = schema.Text(
344+
title="Dummy"
345+
)
346+
```
347+
348+
In supermodel XML, fieldsets are specified by grouping fields within a `<fieldset>` tag:
349+
350+
```xml
351+
<fieldset name="extra" label="Extra info">
352+
<field name="footer" type="zope.schema.TextLine">
353+
<title>Footer text</title>
354+
</field>
355+
<field name="dummy" type="zope.schema.TextLine">
356+
<title>Dummy</title>
357+
</field>
358+
</fieldset>
359+
```
360+
361+
220362
## Advanced
221363

222364
```{note}
@@ -588,17 +730,4 @@ def fields(self):
588730
f.field = schema_field
589731
```
590732

591-
#### Don't use dict `{}` or list `[]` as a default value
592-
593-
Because of how Python object construction works, giving `[]` or `{}` as a default value will make all created field values share this same object.
594-
595-
```{seealso}
596-
[The Hitchhiker's Guide to Python, Common Gotchas](https://docs.python-guide.org/writing/gotchas)
597-
```
598-
599-
Use value adapters instead.
600-
601-
```{seealso}
602-
[`plone.directives.form` documentation of Value adapters](https://pypi.org/project/plone.directives.form/#value-adapters)
603-
```
604733

docs/backend/upgrading/version-specific-migration/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ upgrade-to-52
2626
upgrade-to-python3
2727
upgrade-zodb-to-python3
2828
upgrade-to-60
29+
upgrade-to-61
2930
migrate-to-volto
3031
```

docs/backend/upgrading/version-specific-migration/p4x-to-p5x-upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To upgrade add-ons to Plone 5, see also {doc}`upgrade-addons-to-50`.
2626
- Always upgrade from the latest version of 4.x to the latest version of 5.x (4.3.20 to 5.2.9 at the time of writing).
2727
This will resolve many migration-specific issues.
2828
- If you have problems, ask for help on https://community.plone.org.
29-
- The talk _How to upgrade sites to Plone 5_ has a [video](https://www.youtube.com/watch?t=1m17s&v=bQ-IpO-7F00&feature=youtu.be) and [slides](https://de.slideshare.net/derschmock/upgrade-to-plone-5).
29+
- The talk _How to upgrade sites to Plone 5_ has a [video](https://www.youtube.com/watch?t=1m17s&v=bQ-IpO-7F00&feature=youtu.be) and [slides](https://www.slideshare.net/slideshow/upgrade-to-plone-5/54040952).
3030

3131

3232
(upgrading-plone-4.x-to-5.0-changes-due-to-implemented-plips-label)=

docs/backend/upgrading/version-specific-migration/upgrade-to-60.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ The following example {file}`registry.xml` may be used for configuring TinyMCE w
600600
Please make sure you write valid JSON for the `template` option.
601601

602602
```{seealso}
603-
See also the [TinyMCE 4 to 5 upgrade guide](https://www.tiny.cloud/docs/migration-from-4x/).
603+
See also [Migrating from TinyMCE 4 to TinyMCE 5](https://www.tiny.cloud/docs/tinymce/5/migration-from-4x/).
604604
```
605605

606606
## Viewlets
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
myst:
3+
html_meta:
4+
"description": "How to upgrade to Plone 6.1"
5+
"property=og:description": "How to upgrade to Plone 6.1"
6+
"property=og:title": "How to upgrade to Plone 6.1"
7+
"keywords": "Upgrade, Plone 6"
8+
---
9+
10+
(backend-upgrade-plone-v61-label)=
11+
12+
# Upgrade Plone 6.0 to 6.1
13+
14+
Plone 6.1 has seen the following major changes.
15+
Some may require changes in your setup.
16+
17+
18+
## Drop Python 3.8 and 3.9
19+
20+
We only support Python 3.10, 3.11, and 3.12.
21+
22+
23+
## TinyMCE upgraded in Classic UI
24+
25+
In Plone 6.0, the Classic UI frontend uses TinyMCE 5, a rich text editor for websites.
26+
TinyMCE 5 reached its end of support on April 20, 2023.
27+
For Plone 6.1, Classic UI upgraded TinyMCE from version 5 to 7.
28+
29+
If you upgrade a site using Classic UI from Plone 6.0 to 6.1, you do not need to take any action, unless you implemented custom plugins, or you use a plugin which got removed or moved to premium in TinyMCE versions 6 or 7.
30+
To upgrade your plugin implementation to TinyMCE 7, see the [upgrade guides](https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/#plugins).
31+
32+
33+
### Enable the TinyMCE accordion plugin
34+
35+
1. Go to the {guilabel}`Site Setup > General > TinyMCE` control panel to manage TinyMCE settings.
36+
1. Under the {guilabel}`Plugins and Toolbar` tab, check {guilabel}`accordion` to enable the accordion plugin.
37+
1. Under the same tab, add a menu entry `accordion` for TinyMCE in the control panel by editing the `items` key as shown.
38+
39+
```json
40+
{
41+
"insert": {
42+
"title": "Insert",
43+
"items": "link media | template hr | accordion"
44+
},
45+
}
46+
```
47+
48+
1. Click the {guilabel}`Save` button to save your settings.
49+
1. In the {guilabel}`Security > HTML filtering` control panel, add two new tags to {guilabel}`Valid tags`.
50+
51+
- `summary`
52+
- `details`
53+
54+
1. Also in the {guilabel}`Security > HTML filtering` control panel, add a new attribute to {guilabel}`Custom attributes`.
55+
56+
- `open`
57+
58+
1. For a transform to valid markup of the Bootstrap 5 accordion, use an output filter.
59+
60+
```{seealso}
61+
- [Addon collective.outputfilters.tinymceaccordion](https://github.com/collective/collective.outputfilters.tinymceaccordion)
62+
```
63+
64+
65+
## `z3c.form` and `plone.app.z3cform`
66+
67+
````{todo}
68+
This is a placeholder.
69+
70+
- Update deprecated imports
71+
- New widget templates
72+
73+
```{seealso}
74+
https://github.com/plone/plone.app.z3cform/pull/181
75+
```
76+
````
77+
78+
79+
## `plone.app.multilingual` is a core add-on
80+
81+
`plone.app.multilingual` is the package that adds multilingual support to Plone, allowing the storage and display of content in multiple languages.
82+
In Plone 6.0 and earlier, this was a dependency of `Products.CMFPlone`, making it available for installation in all Plone sites.
83+
In Plone 6.1 it is now a dependency of the `Plone` package.
84+
85+
If your project or your add-on needs this package, and you only depend on `Products.CMFPlone` until now, you should add `plone.app.multilingual` as a dependency.
86+
Then your project or add-on will keep working in both Plone 6.0 and 6.1.
87+
88+
The goal of turning more of the current core packages into core add-ons is to make the core smaller, and in some cases solve circular dependencies.

0 commit comments

Comments
 (0)