[gen] Added a new hook in the object creation algorithm: 'onEditEarly', called before an object being created is linked to its initiator object. Indeed, 'onEdit' is called after the link has been done, and sometimes, the linking may need some information that must be set before calling onEdit, thus via this new method onEditEarly.

This commit is contained in:
Gaetan Delannay 2014-10-17 11:22:49 +02:00
parent 1ed4f0bf23
commit 4577855d60

View file

@ -97,16 +97,20 @@ class BaseMixin:
# Keep in history potential changes on historized fields
obj.historizeData(previousData)
# Call the custom "onEditEarly" if available. This method is called
# *before* potentially linking the object to its initiator.
appyObject = obj.appy()
if created and hasattr(appyObject, 'onEditEarly'):
appyObject.onEditEarly()
# Manage potential link with an initiator object
if created and initiator:
initiator.appy().link(initiatorField.name, obj.appy())
initiator.appy().link(initiatorField.name, appyObject)
# Call the custom "onEdit" if available
msg = None # The message to display to the user. It can be set by onEdit
if obj.wrapperClass:
appyObject = obj.appy()
if hasattr(appyObject, 'onEdit'):
msg = appyObject.onEdit(created)
if hasattr(appyObject, 'onEdit'): msg = appyObject.onEdit(created)
# Update last modification date
if not created:
from DateTime import DateTime