views:

47

answers:

1

I have an AT content type in Plone. It has a number of fields, including a file field. When the user edits an object of this type, how can I tell if a new file was uploaded?

For that matter, how can I tell if any of the fields have been changed?

I am currently using subscribers to hook into the IObjectEditedEvent to do some after the object changes - can I do these things here?

+1  A: 

Yes, IObjectEditedEvent (a direct subclass of IObjectModifiedEvent) is emitted when an Archetypes content object is being changed.

However, the event itself will not tell you if a new file was uploaded. It should be possible however, to obtain the request (context.REQUEST should give you the current request through acquisition, for example) and see if there is a file object there matching the field. If so, the user uploaded a new file for that field and the FileField will have been updated.

Martijn Pieters
Thanks; I used request = zope.app.component.hooks.getSite().REQUEST instead of context, then checked request.has_key('FileField_file')which only seems to appear if FilField has been updated.
askvictor