What is the recommended way to override/alter a registered behavior?
In the document on creating and registering behaviors
The example shows collective.gtags and includes a schema like the one below. It doesn't discuss how a second product might be used to override the registered behavior.
"""Add tags to content
tags = Tags(
What if I wanted to change the behavior, for example, move the tags to the default field set or make tags required.
This was discussed, at least 5 years ago, already, but it doesn't speak conclusively about the final approach to the problem How to change existing dexterity types and behaviors
Coming to a final standard approach was raised again more recently here --> Patterns and anti-patterns with behaviors?
I override the behavior (wildcard.media) with object inheritance. Seems the cleanest and easiest to me so far.
Basically, create a new behavior and stick it full of stuff from the old behavior. Then change only what you need.
'MyProduct' is called 'rfasite' - I'll just cut and paste.
description="Add support for audio fields"
from plone.autoform.interfaces import IFormFieldProvider
from wildcard.media.behavior import namedfile
from wildcard.media.behavior import valid_audio
from wildcard.media.behavior import IAudio
from rfasite.content import _
from zope.interface import provider
audio_file = namedfile.NamedBlobFile(
required=False, #this is what we changed from wildcard.media
Oh, and don't forget to update your types that use it.
TTW I unchecked the audio behavior and checked the 'RFA Audio' behavior.
Also edited my gs profile for types that use the behavior:
<!-- <element value="wildcard.media.behavior.IAudio" /> -->
Now, for the next challenge:
As a behavior modifying developer
I want to hide the old, unmodified behavior from TTW Dexterity Content settings
(and prominently show the new modified behavior in it's place)
So that TTW settings users don't get confused and choose the wrong behavior
To illistrate, I changed my configure.zcml and got the following screenshot.
description="(modified) Add support for audio fields"
Maybe the jbot model would work here.
Couldn't you use overrides.zcml in your product? Similar to...
<configure zcml:condition="installed pp.client.plone.browser"