Commit 3c36a421 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 ec21a348
...@@ -40,16 +40,16 @@ class PortalTypeClassInteractor(Interactor): ...@@ -40,16 +40,16 @@ class PortalTypeClassInteractor(Interactor):
from Products.ERP5Type import WITH_LEGACY_WORKFLOW from Products.ERP5Type import WITH_LEGACY_WORKFLOW
if WITH_LEGACY_WORKFLOW: if WITH_LEGACY_WORKFLOW:
from Products.DCWorkflow.Transitions import Transitions from Products.DCWorkflow.Transitions import Transitions
self.on(Transitions.addTransition).doAfter(self.resetDynamic) self.on(Transitions, 'addTransition').doAfter(self.resetDynamic)
self.on(Transitions.deleteTransitions).doAfter(self.resetDynamic) self.on(Transitions, 'deleteTransitions').doAfter(self.resetDynamic)
from Products.DCWorkflow.Transitions import TransitionDefinition 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 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 from Products.Localizer.Localizer import Localizer
self.on(Localizer.add_language).doAfter(self.resetDynamic) self.on(Localizer, 'add_language').doAfter(self.resetDynamic)
self.on(Localizer.del_language).doAfter(self.resetDynamic) self.on(Localizer, 'del_language').doAfter(self.resetDynamic)
def resetDynamic(self, method_call_object, *args, **kw): def resetDynamic(self, method_call_object, *args, **kw):
""" """
......
...@@ -38,14 +38,14 @@ class FieldValueCacheInteractor(Interactor): ...@@ -38,14 +38,14 @@ class FieldValueCacheInteractor(Interactor):
from Products.Formulator.Field import ZMIField from Products.Formulator.Field import ZMIField
from Products.ERP5Form.ProxyField import ProxyField from Products.ERP5Form.ProxyField import ProxyField
from Products.Formulator.Form import ZMIForm from Products.Formulator.Form import ZMIForm
self.on(ZMIField.manage_edit).doAfter(self.purgeFieldValueCache) self.on(ZMIField, 'manage_edit').doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_edit_xmlrpc).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').doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_tales_xmlrpc).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').doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_edit_target).doAfter(self.purgeFieldValueCache) self.on(ProxyField, 'manage_edit_target').doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_tales).doAfter(self.purgeFieldValueCache) self.on(ProxyField, 'manage_tales').doAfter(self.purgeFieldValueCache)
self.on(ZMIForm.manage_renameObject).doAfter(self.purgeFieldValueCache) self.on(ZMIForm, 'manage_renameObject').doAfter(self.purgeFieldValueCache)
def purgeFieldValueCache(self, method_call_object): def purgeFieldValueCache(self, method_call_object):
""" """
......
...@@ -94,17 +94,18 @@ class InteractorSource: ...@@ -94,17 +94,18 @@ class InteractorSource:
""" """
""" """
def __init__(self, method): def __init__(self, klass, method_name):
""" """
Register method Register method
""" """
self.method = method self.klass = klass
self.method = getattr(self.klass, method_name)
def doBefore(self, action, *args, **kw): def doBefore(self, action, *args, **kw):
""" """
""" """
if not isinstance(self.method, InteractorMethod): if not isinstance(self.method, InteractorMethod):
im_class = self.method.im_class im_class = self.klass
# Turn this into an InteractorMethod # Turn this into an InteractorMethod
interactor_method = InteractorMethod(self.method) interactor_method = InteractorMethod(self.method)
setattr(im_class, self.method.__name__, interactor_method) setattr(im_class, self.method.__name__, interactor_method)
...@@ -116,7 +117,7 @@ class InteractorSource: ...@@ -116,7 +117,7 @@ class InteractorSource:
""" """
""" """
if not isinstance(self.method, InteractorMethod): if not isinstance(self.method, InteractorMethod):
im_class = self.method.im_class im_class = self.klass
# Turn this into an InteractorMethod # Turn this into an InteractorMethod
interactor_method = InteractorMethod(self.method) interactor_method = InteractorMethod(self.method)
setattr(im_class, self.method.__name__, interactor_method) setattr(im_class, self.method.__name__, interactor_method)
...@@ -147,9 +148,9 @@ class Interactor: ...@@ -147,9 +148,9 @@ class Interactor:
raise NotImplementedError raise NotImplementedError
# Interaction implementation # Interaction implementation
def on(self, method): def on(self, *args):
""" """
Parameters may hold predicates ? Parameters may hold predicates ?
no need - use InteractorMethodCall and decide on action 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