|
1 | 1 | --- |
2 | 2 | myst: |
3 | 3 | html_meta: |
4 | | - "description": "" |
5 | | - "property=og:description": "" |
6 | | - "property=og:title": "" |
7 | | - "keywords": "" |
| 4 | + "description": "The fundamental concepts behind behaviors for content types in Plone" |
| 5 | + "property=og:description": "The fundamental concepts behind behaviors for content types in Plone" |
| 6 | + "property=og:title": "The fundamental concepts behind behaviors for content types in Plone" |
| 7 | + "keywords": "Plone, content types, behavior, basics" |
8 | 8 | --- |
9 | 9 |
|
10 | 10 | # Behavior basics |
11 | 11 |
|
12 | | -**The fundamental concepts behind behaviors** |
| 12 | +This chapter describes the fundamental concepts behind behaviors. |
13 | 13 |
|
14 | 14 | Before we dive into the practical examples, we need to explain a few of the concepts that underpin behaviors. |
15 | 15 |
|
16 | | -At the most basic level, a behavior is like a ‘conditional’ adapter. |
17 | | -For a Dexterity content type, the default condition is, "is this behavior listed in the *behaviors* property in the FTI?" |
| 16 | +At the most basic level, a behavior is like a "conditional" adapter. |
| 17 | +For a Dexterity content type, the default condition is, "is this behavior listed in the `behaviors` property in the FTI?" |
18 | 18 | But the condition itself is an adapter; in rare cases this can be overruled. |
19 | | -When a behavior is enabled for a particular object, it will be possible to adapt that object to the behavior’s interface. |
| 19 | +When a behavior is enabled for a particular object, it will be possible to adapt that object to the behavior's interface. |
20 | 20 | If the behavior is disabled, adaptation will fail. |
21 | 21 |
|
22 | | -A behavior consist at the very least of an interface and some metadata, namely a title and a description. |
| 22 | +A behavior consists at the very least of an interface and some metadata, namely a title and a description. |
23 | 23 | In most cases, there is also a *factory*, akin to an adapter factory, which will be invoked to get an appropriate adapter when requested. |
24 | | -This is usually just a class that looks like any other adapter factory, although it will tend to be applicable to *Interface*, *IContentish* or a similarly broad context. |
| 24 | +This is usually just a class that looks like any other adapter factory, although it will tend to be applicable to `Interface`, `IContentish`, or a similarly broad context. |
25 | 25 |
|
26 | 26 | Behaviors may specify a *marker interface*, which will be directly provided by instances for which the behavior is enabled. |
27 | 27 | This is useful if you want to conditionally enable event handlers or view components, which are registered for this marker interface. |
28 | | -Some behaviors have no factory. In this case, the behavior interface and the marker interface must be one and the same. |
29 | | -If a factory is given a marker interface different from the behavior interface must be declared. |
| 28 | +Some behaviors have no factory. |
| 29 | +In this case, the behavior interface and the marker interface must be one and the same. |
| 30 | +If a factory is given, a marker interface different from the behavior interface must be declared. |
30 | 31 |
|
31 | | -Behaviors are registered globally, using the *\<plone.behavior />* ZCML directive. |
32 | | -This results in, among other things, a named utility providing *plone.behavior.interfaces.IBehavior* being registered. |
33 | | -This utility contains various information about the behavior, such as its name, title, interface and (optional) marker interface. |
| 32 | +Behaviors are registered globally, using the `<plone.behavior />` ZCML directive. |
| 33 | +This results in, among other things, a named utility providing `plone.behavior.interfaces.IBehavior` being registered. |
| 34 | +This utility contains various information about the behavior, such as its name, title, interface, and (optional) marker interface. |
34 | 35 | The utility name is the full dotted name to the behavior interface. |
0 commit comments