Commit 4420bce7 authored by Arnaud Fontaine's avatar Arnaud Fontaine

py3: Interactor: No more im_class attribute in Python3.

This changes the API to implement similar feature in Python3, but this should
not be an issue because Interactor are only for non-ERP5 object...
parent 3ddd714c
......@@ -40,16 +40,16 @@ class PortalTypeClassInteractor(Interactor):
from Products.ERP5Type import WITH_LEGACY_WORKFLOW
if WITH_LEGACY_WORKFLOW:
from Products.DCWorkflow.Transitions import Transitions
self.on(Transitions.addTransition).doAfter(self.resetDynamic)
self.on(Transitions.deleteTransitions).doAfter(self.resetDynamic)
self.on(Transitions, 'addTransition').doAfter(self.resetDynamic)
self.on(Transitions, 'deleteTransitions').doAfter(self.resetDynamic)
from Products.DCWorkflow.Transitions import TransitionDefinition
self.on(TransitionDefinition.setProperties).doAfter(self.resetDynamic)
self.on(TransitionDefinition, 'setProperties').doAfter(self.resetDynamic)
from Products.DCWorkflow.Variables import Variables
self.on(Variables.setStateVar).doAfter(self.resetDynamic)
self.on(Variables, 'setStateVar').doAfter(self.resetDynamic)
from Products.Localizer.Localizer import Localizer
self.on(Localizer.add_language).doAfter(self.resetDynamic)
self.on(Localizer.del_language).doAfter(self.resetDynamic)
self.on(Localizer, 'add_language').doAfter(self.resetDynamic)
self.on(Localizer, 'del_language').doAfter(self.resetDynamic)
def resetDynamic(self, method_call_object, *args, **kw):
"""
......
......@@ -38,14 +38,14 @@ class FieldValueCacheInteractor(Interactor):
from Products.Formulator.Field import ZMIField
from Products.ERP5Form.ProxyField import ProxyField
from Products.Formulator.Form import ZMIForm
self.on(ZMIField.manage_edit).doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_edit_xmlrpc).doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_tales).doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_tales_xmlrpc).doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_edit).doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_edit_target).doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_tales).doAfter(self.purgeFieldValueCache)
self.on(ZMIForm.manage_renameObject).doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_edit').doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_edit_xmlrpc').doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_tales').doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_tales_xmlrpc').doAfter(self.purgeFieldValueCache)
self.on(ProxyField, 'manage_edit').doAfter(self.purgeFieldValueCache)
self.on(ProxyField, 'manage_edit_target').doAfter(self.purgeFieldValueCache)
self.on(ProxyField, 'manage_tales').doAfter(self.purgeFieldValueCache)
self.on(ZMIForm, 'manage_renameObject').doAfter(self.purgeFieldValueCache)
def purgeFieldValueCache(self, method_call_object):
"""
......
......@@ -94,17 +94,18 @@ class InteractorSource:
"""
"""
def __init__(self, method):
def __init__(self, klass, method_name):
"""
Register method
"""
self.method = method
self.klass = klass
self.method = getattr(self.klass, method_name)
def doBefore(self, action, *args, **kw):
"""
"""
if not isinstance(self.method, InteractorMethod):
im_class = self.method.im_class
im_class = self.klass
# Turn this into an InteractorMethod
interactor_method = InteractorMethod(self.method)
setattr(im_class, self.method.__name__, interactor_method)
......@@ -116,7 +117,7 @@ class InteractorSource:
"""
"""
if not isinstance(self.method, InteractorMethod):
im_class = self.method.im_class
im_class = self.klass
# Turn this into an InteractorMethod
interactor_method = InteractorMethod(self.method)
setattr(im_class, self.method.__name__, interactor_method)
......@@ -147,9 +148,9 @@ class Interactor:
raise NotImplementedError
# Interaction implementation
def on(self, method):
def on(self, *args):
"""
Parameters may hold predicates ?
no need - use InteractorMethodCall and decide on action
"""
return InteractorSource(method)
return InteractorSource(*args)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment