Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic schema update fix broke versioned File and Image content types #57

Closed
datakurre opened this issue Apr 29, 2021 · 1 comment · Fixed by #58
Closed

Dynamic schema update fix broke versioned File and Image content types #57

datakurre opened this issue Apr 29, 2021 · 1 comment · Fixed by #58

Comments

@datakurre
Copy link
Member

datakurre commented Apr 29, 2021

It seems that fix for plone/plone.dexterity#136 in plone/plone.dexterity@8fd6060 broke editing of versioned instances of File and Image content type (and other using the same plone.app.versioningbehavior modifiers).

How to reproduce:

  1. Start Plone 5.2.4 (probably affects also 5.2.3)
  2. Enable versioning on File or Image content types
  3. Create Image or File content
  4. Save Image or File schema at Dexterity control panel
  5. Edit and save existing image or file content again.

Errors should look like this:

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 371, in publish_module
  Module ZPublisher.WSGIPublisher, line 266, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 63, in call_object
  Module plone.z3cform.layout, line 63, in __call__
  Module plone.z3cform.layout, line 47, in update
  Module plone.dexterity.browser.edit, line 58, in update
  Module plone.z3cform.fieldsets.extensible, line 65, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 145, in update
  Module plone.app.z3cform.csrf, line 22, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 315, in __call__
  Module z3c.form.button, line 170, in __call__
  Module plone.dexterity.browser.edit, line 30, in handleApply
  Module z3c.form.group, line 124, in applyChanges
  Module zope.event, line 32, in notify
  Module zope.component.event, line 27, in dispatch
  Module zope.component._api, line 134, in subscribers
  Module zope.interface.registry, line 448, in subscribers
  Module zope.interface.adapter, line 619, in subscribers
  Module zope.component.event, line 36, in objectEventNotify
  Module zope.component._api, line 134, in subscribers
  Module zope.interface.registry, line 448, in subscribers
  Module zope.interface.adapter, line 619, in subscribers
  Module plone.app.versioningbehavior.subscribers, line 62, in create_version_on_save
  Module Products.CMFEditions.CopyModifyMergeRepositoryTool, line 332, in save
  Module Products.CMFEditions.CopyModifyMergeRepositoryTool, line 500, in _recursiveSave
  Module Products.CMFEditions.ArchivistTool, line 267, in prepare
  Module Products.CMFEditions.ModifierRegistryTool, line 135, in getReferencedAttributes
  Module plone.app.versioningbehavior.modifiers, line 117, in getReferencedAttributes
  Module Products.CMFEditions.CopyModifyMergeRepositoryTool, line 410, in retrieve
  Module Products.CMFEditions.CopyModifyMergeRepositoryTool, line 558, in _retrieve
  Module Products.CMFEditions.CopyModifyMergeRepositoryTool, line 634, in _recursiveRetrieve
  Module Products.CMFEditions.ArchivistTool, line 342, in retrieve
  Module Products.CMFEditions.ArchivistTool, line 510, in __getitem__
  Module Products.CMFEditions.ModifierRegistryTool, line 162, in reattachReferencedAttributes
  Module plone.app.versioningbehavior.modifiers, line 188, in reattachReferencedAttributes
TypeError: ('Could not adapt', <Image at example.png>, <InterfaceClass plone.dexterity.schema.generated.Plone_5_1619726225_2_939166_0_Image>)

Schema identifiers are saved with separately saved attributes (as strings) to make it possibly to retrieve and use the schema to properly set the attribute back to cloned object. Saving a new version probably needs to wake up the previous version for reason or another, and because the woken gets the current dynamic schema version, it cannot adapt to the version retrieved with the old name.

https://community.plone.org/t/could-not-adapt-error-on-select-file-objects-with-versioning-enabled/13754/13

@datakurre
Copy link
Member Author

datakurre commented Apr 29, 2021

Really need to write a test for this first to prevent further regression.

That aside, I wonder, if 'plone.dexterity.schema.generated.Plone_5_1619723628_2_8913827_0_File' is a clear pattern enough that if iface name starts with plone.dexterity.schema.generated. we could simply get the content type name after _0_ and use SCHEMA_CACHE.get() instead of resolveDottedName.

https://github.com/plone/plone.app.versioningbehavior/blob/master/plone/app/versioningbehavior/modifiers.py#L185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant