ERP5: check constraints in notificiation tool's sendMessage
-
Owner
@jerome this changes introduces compatibility issues, if constraint checking is activated by default.
Then, wouldn't it be better to raise a ValidationFailed error instead of a ValueError. ValidationFailed at least is handled by Base_workflowStatusModify, and so, error will be correctly displayed to user if email sending is rejected during a workflow transition.
-
Owner
@romain thanks, you're right. This change does break compatibility when using
portal_notification.sendMessage
to send email notification with some constraints defined on Mail Message portal type.I am working on a patch making
check_consistency
False by default. The check for recipient email address are anyway done again in MailMessage_send so this case will fail early enough and we do not need to have this check in notification tool (this we our problem in the first place).
About raising a ValidationFailed, one potential problem is that Base_workflowStatusModify commits the transactions, so if we pass store_as_event=True, we may keep in event_module some events that were not actually sent, especially when multiple recipients.
Another problem might be that the constraint message will likely not be user friendly enough in that context (because they are usually written as an validation error when validating the event).
This
check_consistency
does not change the fact that the caller of sendMessage is expected to check that conditions are OK before calling sendMessage. This check_consistency is just so that we have an error instead of creating invalid events. I never saw it as something that should be used for user interaction. -
Owner
There was a problem in that first commit. I amended it as 3d1a8811 and now tests are passing:
https://nexedi.erp5.net/test_result_module/20161007-5AA51526
https://nexedi.erp5.net/test_result_module/20161007-86BBCD2
OK to merge this one ?
-
Owner
ok