# HG changeset patch # User Thierry Florac # Date 1505902283 -7200 # Node ID fb51fb6d6129ca609102eccf805f8f498da977dc # Parent 3e6b4514cacbe87ffcfbea75c0a05395642e58d5 Switch from callbacks to events in several forms output diff -r 3e6b4514cacb -r fb51fb6d6129 src/pyams_content/component/association/zmi/__init__.py --- a/src/pyams_content/component/association/zmi/__init__.py Tue Sep 19 13:43:54 2017 +0200 +++ b/src/pyams_content/component/association/zmi/__init__.py Wed Sep 20 12:11:23 2017 +0200 @@ -61,9 +61,12 @@ associations_table.update() return {'status': 'success', 'message': self.request.localizer.translate(_("Association was correctly added.")), - 'callback': 'PyAMS_content.associations.afterUpdateCallback', - 'options': {'parent': associations_table.id, - 'table': associations_table.render()}} + 'events': [{ + 'event': 'PyAMS_content.changed_item', + 'options': {'object_type': 'associations', + 'object_name': associations_table.id, + 'table': associations_table.render()} + }]} class AssociationItemAJAXEditForm(AJAXEditForm): @@ -75,9 +78,12 @@ associations_table.update() return {'status': 'success', 'message': self.request.localizer.translate(self.successMessage), - 'callback': 'PyAMS_content.associations.afterUpdateCallback', - 'options': {'parent': associations_table.id, - 'table': associations_table.render()}} + 'events': [{ + 'event': 'PyAMS_content.changed_item', + 'options': {'object_type': 'associations', + 'object_name': associations_table.id, + 'table': associations_table.render()} + }]} # diff -r 3e6b4514cacb -r fb51fb6d6129 src/pyams_content/component/illustration/zmi/__init__.py --- a/src/pyams_content/component/illustration/zmi/__init__.py Tue Sep 19 13:43:54 2017 +0200 +++ b/src/pyams_content/component/illustration/zmi/__init__.py Wed Sep 20 12:11:23 2017 +0200 @@ -122,14 +122,15 @@ if 'data' in changes.get(IIllustration, ()): # we have to commit transaction to be able to handle blobs... ITransactionManager(self.context).get().commit() - context = IIllustration(self.context) - form = IllustrationPropertiesInnerEditForm(context, self.request) + form = IllustrationPropertiesInnerEditForm(self.context, self.request) form.update() - output.setdefault('callbacks', []).append({ - 'callback': 'PyAMS_content.illustration.afterUpdateCallback', - 'options': {'parent': '{0}_{1}_{2}'.format(self.context.__class__.__name__, - getattr(form.getContent(), '__name__', 'noname').replace('++', ''), - form.id), + output.setdefault('events', []).append({ + 'event': 'PyAMS_content.changed_item', + 'options': {'object_type': 'illustration', + 'object_name': '{0}_{1}_{2}'.format( + self.context.__class__.__name__, + getattr(form.getContent(), '__name__', 'noname').replace('++', ''), + form.id), 'form': form.render()} }) return output diff -r 3e6b4514cacb -r fb51fb6d6129 src/pyams_content/component/illustration/zmi/paragraph.py --- a/src/pyams_content/component/illustration/zmi/paragraph.py Tue Sep 19 13:43:54 2017 +0200 +++ b/src/pyams_content/component/illustration/zmi/paragraph.py Wed Sep 20 12:11:23 2017 +0200 @@ -170,14 +170,15 @@ if 'data' in updated: # we have to commit transaction to be able to handle blobs... ITransactionManager(self.context).get().commit() - context = IIllustrationParagraph(self.context) - form = IllustrationInnerEditForm(context, self.request) + form = IllustrationInnerEditForm(self.context, self.request) form.update() - output.setdefault('callbacks', []).append({ - 'callback': 'PyAMS_content.illustration.afterUpdateCallback', - 'options': {'parent': '{0}_{1}_{2}'.format(self.context.__class__.__name__, - getattr(form.getContent(), '__name__', 'noname').replace('++', ''), - form.id), + output.setdefault('events', []).append({ + 'event': 'PyAMS_content.changed_item', + 'options': {'object_type': 'illustration', + 'object_name': '{0}_{1}_{2}'.format( + self.context.__class__.__name__, + getattr(form.getContent(), '__name__', 'noname').replace('++', ''), + form.id), 'form': form.render()} }) return output diff -r 3e6b4514cacb -r fb51fb6d6129 src/pyams_content/component/paragraph/zmi/html.py --- a/src/pyams_content/component/paragraph/zmi/html.py Tue Sep 19 13:43:54 2017 +0200 +++ b/src/pyams_content/component/paragraph/zmi/html.py Wed Sep 20 12:11:23 2017 +0200 @@ -145,9 +145,10 @@ if 'body' in changes.get(IHTMLParagraph, ()): associations_table = AssociationsTable(self.context, self.request, None) associations_table.update() - output.setdefault('callbacks', []).append({ - 'callback': 'PyAMS_content.associations.afterUpdateCallback', - 'options': {'parent': associations_table.id, + output.setdefault('events', []).append({ + 'event': 'PyAMS_content.changed_item', + 'options': {'object_type': 'associations', + 'object_name': associations_table.id, 'table': associations_table.render()}}) return output @@ -178,9 +179,10 @@ if 'body' in changes.get(IHTMLParagraph, ()): associations_table = AssociationsTable(self.context, self.request, None) associations_table.update() - output.setdefault('callbacks', []).append({ - 'callback': 'PyAMS_content.associations.afterUpdateCallback', - 'options': {'parent': associations_table.id, + output.setdefault('events', []).append({ + 'event': 'PyAMS_content.changed_item', + 'options': {'object_type': 'associations', + 'object_name': associations_table.id, 'table': associations_table.render()} }) return output