Plone: override registry record, if it is not possible to delete them
Sometimes a plone.registry record can not deleted normally because of some exceptions. But it might be possible to override them with somthing new and clean.
Error on delete
Errors like this can happen, if you try to deleted a record and the underlying code is not valid.
TypeError: ('object.__new__(RegistryFieldDefaultFactory) is not safe, use Persistence.Persistent.__new__()', <function _reconstructor at 0x7f341b1c5a28>, (<class 'example.behavior.settings.example_settings.RegistryFieldDefaultFactory'>, <type 'object'>, None))
Override a record
You can start Plone in debug shell:
./bin/instance debug portal = app.Plone registry = portal.portal_registry from plone.registry import Record from plone.registry import field registry.records['example.behavior.settings.example_settings.ISettings.projects'] = Record( field.TextLine(title=u"Projects"), u"Test") import transaction transaction.commit()
Delete the record
Now we can delete the record without an error.
del registry.records['example.behavior.settings.example_settings.ISettings.projects'] transaction.commit()