Somehow I keep returning to this post with my Google searches, so it might help some future reader of this post to add a possible solution for pbauer's problem. It seems that the tagged value is dependent on the plugin that processes the values. In my case, this thing worked, to hide some fields.
from zope.interface import Interface
from plone.autoform.interfaces import OMITTED_KEY
from plone.restapi import behaviors
behaviors.IBlocks.setTaggedValue(OMITTED_KEY,
[
(Interface, 'blocks', 'true'),
(Interface, 'blocks_layout', 'true'),
])
I think, for pbauer's example to work, the Interface class should be used directly, not its dotted name. I wonder if, in my case, the Interface stands for the context, the request or the view.
This, of course, later I've found that this is already documented here: https://docs.plone.org/external/plone.app.dexterity/docs/reference/misc.html
And another way that I've discovered can be used to tweak schemas. I have the need to add some description to the IRichtext.text field, so I've created this schema plugin:
from zope.component import adapter
from zope.interface import implementer
from plone.autoform.interfaces import IFormFieldProvider
from plone.supermodel import interfaces
@implementer(interfaces.ISchemaPlugin)
@adapter(IFormFieldProvider)
class SchemaTweaks(object):
"""
"""
order = 999999
def __init__(self, schema):
self.schema = schema
def __call__(self):
if self.schema.getName() == 'IRichTextBehavior':
field = self.schema['text']
field.description = u'Rich text, double click for toolbar.'
if self.schema.getName() == 'IBlocks':
del self.schema._Element__tagged_values[
'plone.supermodel.fieldsets'
]
And I've registered this as a simple adaptor with:
<adapter factory=".patches.SchemaTweaks" name="schema.tweaks" />
Probably a generic mechanism to allow registration of named adapters (with the name being the schema name) to customize schemas could be created, but I'm not sure there would be much to be gained over the example above.