If you export 'datagridfield' settings from registry and put them in (your profile's) registry.xml: I dont think it works. I needed to put it in setuphandlers. py
Not off topic for me - I will make a new thread, going into the consequences of storing DictRow fields in the registry and requiring additional fields that are not visible to the end user (in my case, JWT token and its expiration). This was easy when I had only one connection, but could get interesting now that there are more.
I wish someone had shared something like this... For my future self:
# -*- coding: UTF-8 -*-
from ..interfaces import IRestConnectionsSchema
from plone.app.registry.browser import controlpanel
from plone.registry.interfaces import IRegistry
from Products.CMFPlone import PloneMessageFactory as _
from z3c.form.interfaces import HIDDEN_MODE
class RestClientSettingsEditForm(controlpanel.RegistryEditForm):
schema = IRestConnectionsSchema
schema_prefix = 'collective.restclient'
label = _(u'RestClient Connections')
description = _(u'')
def updateFields(self):
super(RestClientSettingsEditForm, self).updateFields()
def updateWidgets(self):
super().updateWidgets()
columns = self.widgets['restclient_connections'].columns
for col in columns:
if col['name'] in ('jwt_token', 'token_expires'):
col['mode'] = HIDDEN_MODE
self.widgets['restclient_connections'].updateWidgets()
class RestClientControlPanel(controlpanel.ControlPanelFormWrapper):
form = RestClientSettingsEditForm