Plone 5 - Dexterity - EMail-Notification on Field change - Issue with Sharing

Hello,

I created a notification for members of a Plone site once a software version number was added/changed thus they could update the version information of their templates/extensions. I created this notification with some hints from the Plone community:

def notifiyAboutNewVersion(eupproject, event):
if hasattr(event, 'descriptions') and event.descriptions:
for d in event.descriptions:
if d.interface is IEUpCenter and 'available_versions' in d.attributes:
users=api.user.get_users()
message='We added a new version of LibreOffice to the list.\n'
'Please add this version to your LibreOffice extension release(s), '
'if it is (they are) compatible with this version.\n\n'
'Kind regards,\n\n'
'The LibreOffice Extension and Template Site Administration Team'
for f in users:
mailaddress = f.getProperty('email')
api.portal.send_email(
recipient=mailaddress,
sender="noreply@libreoffice.org",
subject="New Version of LibreOffice Added",
body=message,
)

This notification works fine. I could adapt it to plone.api.
But I have an issue with the sharing feature of Plone (5). If I try use this sharing feature to give all logged-in user the option to add content objects to the folder I get the following traceback:

Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.app.workflow.browser.sharing, line 59, in call
Module plone.app.workflow.browser.sharing, line 110, in handle_form
Module zope.event, line 31, in notify
Module zope.component.event, line 24, in dispatch
Module zope.component._api, line 136, in subscribers
Module zope.component.registry, line 321, in subscribers
Module zope.interface.adapter, line 585, in subscribers
Module zope.component.event, line 32, in objectEventNotify
Module zope.component._api, line 136, in subscribers
Module zope.component.registry, line 321, in subscribers
Module zope.interface.adapter, line 585, in subscribers
Module tdf.extensionuploadcenter.notifications, line 9, in notifiyAboutNewVersion
Module ZPublisher.HTTPRequest, line 1391, in getattr
AttributeError: interface

It's the following line of my source code that causes the issue:

if d.interface is IEUpCenter and 'available_versions' in d.attributes:

Thanks for any hints
Andreas

in

if d.interface is IEUpCenter and 'available_versions' in d.attributes:
could you use

if hasattr(d, 'interface') and d.interface is IEUpCenter and 'available_versions' in d.attributes:

Hello,

thanks, that fixed the issue.

Andreas

1 Like