Working with Plone 4.3.15 I am trying to find a general way (or just a way) of retrieving via Python the Plone Configuration settings (see the first image) of a Plone instance. As an example, for the Mail Settings I would like to retrieve the values of the fields that can be seen in the second image. And I would like to do the same with all the panels and settings. Thus far I've had no luck. Below are some of my attempts to do so (the most promising ones).
Attempt 1
I have tried using the registry method forInterface
with the different Schema interfaces as shown below (where ISomeSchema
is a generic name I'm using here but could be, for exampe IMailSchema
):
reg = getUtility(IRegistry)
some_settings = reg.forInterface(ISomeSchema)
However, I keep getting the error:
KeyError: 'Interface 'Products.CMFPlone.interfaces.controlpanel.ISomeSchema' defines a field 'some_field', for which there is no record.'
which isn't strange at all, since not all the fields have a record set (although it also gives the same error for some fields which are indeed set. Related: https://github.com/plone/Products.CMFPlone/issues/1394). However, when I call the same forInterface
method with check=False
and then query the different fields all of them are returning None
.
Attempt 2
I have also tried using the function getFields
from zope.schema
:
zope.schema.getFields(ISomeSchema)
and I am actually getting back something like:
'field_name', <zope.schema._bootstrapfields.SomeField object at 0x[...]>
However, it seems to me that I am getting something like the definition of the field and I have not being able to retrieve its current value from there.
Question
Is there any way in which I can achieve this? Or could I be pointed in the right direction?
If there is any further information I can provide I will do so willingly. Also, if haven't been clear enough I can try to explain myself better. Thanks in advance!