Commit 38676af4 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Fixed issue related to inheritances in Form fields and ZMI.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16636 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 261d98c6
from Products.ERP5Type.Accessor.Accessor import Accessor as Method from Products.ERP5Type.Accessor.Accessor import Accessor as Method
from Products.ERP5Type.Base import _aq_reset from Products.ERP5Type.Base import _aq_reset
import Acquisition
from Acquisition import aq_parent
""" """
Current implementation uses callable objects. Current implementation uses callable objects.
Using decorator would be more modern and consistent with Using decorator would be more modern and consistent with
...@@ -27,7 +28,10 @@ class InteractorMethodCall: ...@@ -27,7 +28,10 @@ class InteractorMethodCall:
self.method = method self.method = method
def __call__(self): def __call__(self):
return self.method(self.instance, *self.args, **self.kw) # We use self.__dict__['instance'] to prevent inserting the
# InteractorMethodCall instance in the acquisition chain
# which has some side effects
return self.method(self.__dict__['instance'], *self.args, **self.kw)
class InteractorMethod(Method): class InteractorMethod(Method):
...@@ -174,6 +178,37 @@ class FieldValueInteractor(Interactor): ...@@ -174,6 +178,37 @@ class FieldValueInteractor(Interactor):
Form.purgeFieldValueCache() Form.purgeFieldValueCache()
ProxyField.purgeFieldValueCache() ProxyField.purgeFieldValueCache()
class TypeInteractorExample(Interactor):
def __init__(self, portal_type):
self.portal_type = portal_type
def install(self):
from Products.CMFCore.TypesTool import TypesTool
self.on(TypesTool.manage_edit).doAfter(self.doSomething)
def doSomething(self, method_call_object):
if self.portal_type == method_call_object.instance.portal_type:
pass
# do whatever
class InteractorOfInteractor(Interactor):
def __init__(self, interactor):
self.interactor = interactor
def install(self):
self.on(interactor.doSomething).doAfter(self.doSomething)
def doSomething(self, method_call_object):
pass
#test = AqDynamicInteractor()
#test.install()
#interactor_of_interactor = InteractorOfInteractor(test)
#interactor_of_interactor.install()
# This is used in ERP5Form and install method is called in ERP5Form # This is used in ERP5Form and install method is called in ERP5Form
fielf_value_interactor = FieldValueInteractor() fielf_value_interactor = FieldValueInteractor()
#fielf_value_interactor.install() fielf_value_interactor.install()
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