寻找和添加行为 Dexterity的行为概义可以重用功能、重用字段定义,而且这些行为可以基于类来打开或关闭。 每一个行为都有一个唯一接口。当一个行为在一个类型上启用时, you will be able to adapt that type to the behavior's interface. If the behavior is disabled, the adaptation will fail. 行为接口也能被标记作为一个IFormFieldsProvider,这种情况下它将添加字段到标准的添加和编辑表单。 Finally, a behavior may imply a sub-type: a marker interface which will be dynamically provided by instances of the type for which the behavior is enabled. 在这里我们不介绍怎样写一个新的行为,我们演示怎样在一个类型上启用行为。事实上我们已看过一个标准的行为怎样应用到我们的样例类型,通过GenericSetup,在FTI中注册:<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle" />
</property>其他的行为也可以用同样的方式添加。 行为用<plone:behavior />语句在 ZCML注册,当注册后,一个行为将创建一个提供IBehavior接口的全局utility,这个utility提供如标题、描述等行为的元数据。你可以发现和应用行为通过 Dexterity Content Types 控制面板,plone.app.dexterity包提供一系列标准行为,详情参考本手则后面部分附件。