Who was the last to change a specific image?

i'm using the rest-api of plone6 for python3.
given a specific image, how do i find out the username of the person who was the last to change that image?

normal pages have a history which can be used for this. but images don't seem to have a history.

This information is in general not available.

You need to enable versioning for images. Check this topic for how to do so for a specific content type:

Ok, thanks! I'll ask our admin whether they will enable versioning for images.

If you enable versioning for images and files, you will blow up your database.
This is in general not recommended and unlikely the right approach for getting this kind of information. At least not for content that changes frequently.

Your use case might be covered by:

You might also check other similar plugins on PyPI, GitHub or https://pag.derico.tech/.

2 Likes

Another option would be to use zopyx.plone.persistentlogger, which allows for a unified approach to per-object logging.

A typical integration via an event subscriber looks like this:

mport zope.component
from onkopedia.policy.behaviors import IGuideline
from onkopedia.policy.browser.addform import blacklist_portlets
from onkopedia.policy.i18n import MessageFactory as _
from plone.behavior.interfaces import IBehaviorAssignable
from plone.dexterity.interfaces import IDexterityFTI
from xmldirector.connector.connector import IConnector
from zopyx.plone.persistentlogger.logger import IPersistentLogger


def get_all_fields(context):
    """Return all fields (including behavior fields) of a context object
    as dict fieldname -> field.
    """

    schema = zope.component.getUtility(
        IDexterityFTI, name=context.portal_type
    ).lookupSchema()
    fields = dict((fieldname, schema[fieldname]) for fieldname in schema)

    assignable = IBehaviorAssignable(context)
    for behavior in assignable.enumerateBehaviors():
        behavior_schema = behavior.interface
        fields.update((name, behavior_schema[name]) for name in behavior_schema)

    return fields


def created(event):
    """Created event"""

    obj = event.object
    if not IConnector.providedBy(obj):
        return

    # black list all portlets
    blacklist_portlets(event.object)


def notify_message(event):
    """Notify editor upon metadata changes"""

    obj = event.object
    if not IConnector.providedBy(obj):
        return

    fields = get_all_fields(obj)
    data = dict()
    for f in fields:
        v = getattr(obj, f, None)
        if callable(v):
            v = v()
        data[f] = v
    IPersistentLogger(obj).log(u"Metadata change", details=data)

    # set document language to configured guideline language
    obj.language = IGuideline(obj).gl_language

    obj.plone_utils.addPortalMessage(
        _(
            "The metadata has changed. Consider to re-run the conversion/publication process."
        )
    )

The notify_message() function is triggered for each object change, capturing and storing all metadata in the persistent logger. This log is then directly saved on the associated object. The relevant content object contains a view resembling the one depicted above. The specific information gathered and logged is customizable based on your application's needs. While some coding is necessary, it does not require an extensive amount.

3 Likes

thanks for your hints. i'll give that to our admins and hope they'll implement one of those solutions.
however, imho it's a pity that plone does not seem to be able to provide this data by default. i think that mediawiki has solved this better.

Because Wikimedia do versions everything by default. You can version the images in Plone too.

If there would

This feature is implemented through versioning, if you need it.
Wild guess: the majority of the users does not need it, does not use it, disabled this feature.

As others have mentioned, this feature is opt-in, with caveats. But maybe, it sounds like you simply want an audit log, not necessarily versioning โ€” in that case, I would look at collective.fingerpointing.