Commit f5842fd1 authored by Arnaud Fontaine's avatar Arnaud Fontaine

py3: No more im_class attribute in Python3. API change but Interactor not...

py3: No more im_class attribute in Python3. API change but Interactor not used/recommended anymore (ERP5 object)...
parent d7ed1c81
......@@ -48,8 +48,8 @@ class PortalTypeClassInteractor(Interactor):
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,25 @@ class InteractorSource:
"""
"""
def __init__(self, method):
def __init__(self, *args):
"""
Register method
"""
self.method = method
if len(args) == 1:
self.klass = method.im_class
self.method = method
else:
# No im_class on Python3 and Interactors only makes sense with non-ERP5
# objects anyway, so add a class argument to InteractorSource to make it
# simple
self.klass = args[0]
self.method = getattr(self.klass, args[1])
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 +124,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 +155,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