Update registry entries in upgrade profile

If one has a profile, with registry.xml

<records interface="my.add.interfaces.IMySettings">
	<value key="somesetting">default_setting</value>
</records>

and the settings are defined (for a control panel) in interfaces.MySettings as:

somesettings = schema.Choice(
     values=['one', 'two'],
)

How do one make an upgrade profile when options for some settings should be:

values=['one', 'two', 'many']

Maybe getting the old list of values with api.portal.get_registry_record, extend the list and set them with api.portal.set_registry_record? (https://training.plone.org/5/mastering-plone/registry.html#accessing-and-modifying-values-in-the-registry). Not sure if you meant sth like this.

I would look for an equivalent to the purge keyword

https://docs.plone.org/develop/addons/components/genericsetup.html#the-purge-attribute

<record name="my.package.animalFood">
    <value purge="false">
        <element key="Squirrel">Nuts</element>
        <element key="Piranha">Other piranha</element>
    </value>
</record>

If it could be done like that, it would be easy and 'clean'.

Question: How do I let an upgrade step/profile 'run just the xml files'?

would something like this be possible or do I need to run this from code ( handler = something ) ?

  <genericsetup:upgradeStep
  name="upgrade"
  source="1010"
  destination="1020"
  title="Myaddon: Upgrade"
  directory="profiles/upgrade"
  description="upgrade to version 2"
  provides="Products.GenericSetup.interfaces.EXTENSION"
  />

Importing a GenericSetup profile always runs all steps. For steps controlled by something in the file system, this is no problem: put into the "profile" folder only things for steps you want to get run. Generic handlers typically explicitly look for a file in the profile directory - just to let a profile control whether the step should do something.

You need to write an upgrade step, search for all contents with the related interface. Then you iterate over the results and update somesettings as needed.

There is a way to search by interface:

from collective.example.interfaces import IMyInterface
from plone import api

catalog = api.portal.get_tool('portal_catalog')
brains = catalog(object_provides=IMyInterface.__identifier__)

note: I typed it directly here on the reply box, so there might be typos :sweat_smile:

You're correct.

Thanks a lot.