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

IObjectModifiedEvent always shows namedfile has changed #41

Closed
flipmcf opened this issue Nov 20, 2019 · 1 comment · Fixed by #42
Closed

IObjectModifiedEvent always shows namedfile has changed #41

flipmcf opened this issue Nov 20, 2019 · 1 comment · Fixed by #42
Assignees
Labels

Comments

@flipmcf
Copy link
Contributor

@flipmcf flipmcf commented Nov 20, 2019

https://community.plone.org/t/namedblobfile-in-event-description-always-modified/10810

If I have a simple namedblobfile in my dexterity type:

class IVideo(model.Schema)
    video_file = NamedBlobFile(
        title=_('video file'),
    )

Then register an event handler when a Video is modified:

  <subscriber
       for="myproduct.video.IVideo
               zope.lifecycleevent.interfaces.IObjectModifiedEvent"
       handler=".events.modifyVideo"
  />

And try to see if the video file was modified:

def modifyVideo(context, event)
    file_changed = False
    if hasattr(event, 'descriptions') and event.descriptions:
        for d in event.descriptions:
            if d.interface is IVideo and 'video_file' in d.attributes:
                file_changed = True

the field 'video_file' will always be present in the list.

When "Keep Existing File" is chosen in the widget, the widget should (??) set the new value to z3c.form.interfaces.NOT_CHANGED according to z3c.form.form 'applyChanges' function.

I'm not sure at all how to fix this myself. I hope I can get some help, if I analyzed the bug properly.

I don't see any documentation for the NOT_CHANGED interface flag - only code and a comment:

    # If the value is NOT_CHANGED, ignore it, since the widget/converter
    # sent a strong message not to do so.

https://github.com/zopefoundation/z3c.form/blob/e882d357190f6a5bc48dcefe7adc9cfacc9a0ad8/src/z3c/form/form.py#L43

@flipmcf

This comment has been minimized.

Copy link
Contributor Author

@flipmcf flipmcf commented Nov 20, 2019

I'm willing to work on this issue, if it is an issue, but at the time of this writing I have zero experience in widgets. Help would be appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.