plone / plone.app.registry

provides Plone UI, persistence and GenericSetup integration for plone.registry
https://pypi.org/project/plone.app.registry
2 stars 6 forks source link

Default value in registry.xml overrides the value in the registry #50

Open batlock666 opened 3 years ago

batlock666 commented 3 years ago

I have this in my registry.xml:

<registry>

  <record name="ugent.development.foobar">
    <field type="plone.registry.field.Int">
      <title>Foobar</title>
      <description>Foobar.</description>
      <required>False</required>
      <default>-1</default>
    </field>
  </record>

</registry>

This adds the record ugent.development.foobar to the registry, and gives it the default value -1. Now I can modify this value in the registry to eg. 123. However, if I run the same profile again, the value in the registry is changed back to -1. Is this normal? I would think that once a record is created, the default value is ignored.

jensens commented 3 years ago

Smells like a bug. I think a test would be good to show this.

thet commented 1 year ago

I just stumbled over the same:

Reading this until L324 https://github.com/plone/plone.app.registry/blob/3f3e69cfd3f8c5b2e16cca9a32b247176acf7f9b/plone/app/registry/exportimport/handler.py#L269 looks like defining a default value would always overwrite any existing values.

thet commented 1 year ago

Also, slightly related: If you set your value to purge="False" that will only have an effect if it is of type list, tuple, set, frozenset or dict. All other values, e.g. Booleans or a string from a TextLine would be overwritten.