Patterns and anti-patterns with behaviors?

I am currently working on a Plone 5 migration where the original system is heavily based on ATSchemaExtender. The new functionality is likely based on behaviors but the question is about how to deal with all variations:

"Turn off a particular field for all content-types" - likely one wants to redefine the behaviors of the affected FTIs and omitting the related behavior - EASY

"Turn off a particular field for particular content-type" - same but you only touch the FTI of the related content-type - EASY

"Turn on a particular field for a particular content-types" - same, you only add the related behavior to the FTI - EASY

"Show field XXX only to managers" - DX defines read and write permissions which can be defined either as partf of the XML supermodel or through Python. But how would you redefine the behavior (the security settings) of a behavior? - TRICKY

"Replace the image field of News Item with a custom image field implementation" - replacing the lead image behavior is likely the way to to here - EASY
but how would you replace field (implementation) of a behavior that provides severall other fields too :thinking:

"Move field XXX into fieldset YYY", "Move field 'show_description' after field 'description'" ... I am aware that you can define the field ordering in fieldsets inside your schema or the XML supermodel...TRICKY.

"Add a custom validator to an existing image field" - how? TRICKY

"Make field XXX on content-type YYYY required" - how? TRICKY

All requirements above basically affect the default Plone content types...any thoughts how to approach the more tricky parts in a minimal and sane way?

3 Likes

Related discussion thread:

I was just thinking about this again. I think we have to throw ourselves on a grenade and write "How we did it" and act as if we are the ultimate authority and we are absolutely right.

Once that is done, the correct answer will manifest itself when we are inevitably corrected.


Can you add my pet user story? "Make an existing field required / optional "

2 Likes

Yes please. I'm looking into the wildcard.media IAudio behavior, which sets defaults to required when I want them to be optional (you wrote about this problem in the past How to change existing dexterity types and behaviors - #13 by flipmcf)

For reference, my generic question --> Override a schema provided by a behavior

5 years later I'm thinking...:

1 Like