Commit 58b44185 authored by Yusei Tahara's avatar Yusei Tahara

Added a interactor definition for ERP5Form's field performance improvement.

Commented out experimental interactors.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16500 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fb8b3986
...@@ -88,27 +88,61 @@ class Interactor: ...@@ -88,27 +88,61 @@ class Interactor:
""" """
return InteractorSource(method) return InteractorSource(method)
class AqDynamicInteractor(Interactor):
def install(self): ## #
""" ## # Experimental part
Installs interactions ## #
""" ## class AqDynamicInteractor(Interactor):
from Products.ERP5.Interaction import InteractionDefinition
self.on(InteractionDefinition.setProperties).doAfter(self.resetAqDynamic, 1, 2, toto="foo")
self.on(InteractionDefinition.addVariable).doAfter(self.resetAqDynamic, 1, 2, toto="foo")
def uninstall(self): ## def install(self):
""" ## """
Uninstall interactions ## Installs interactions
""" ## """
## from Products.ERP5.Interaction import InteractionDefinition
## self.on(InteractionDefinition.setProperties).doAfter(self.resetAqDynamic, 1, 2, toto="foo")
## self.on(InteractionDefinition.addVariable).doAfter(self.resetAqDynamic, 1, 2, toto="foo")
## def uninstall(self):
## """
## Uninstall interactions
## """
## # Interaction example
## def resetAqDynamic(self, method_call_object, a, b, toto=None):
## """
## Reset _aq_dynamic
## """
## _aq_reset()
## 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()
# Interaction example
def resetAqDynamic(self, method_call_object, a, b, toto=None):
"""
Reset _aq_dynamic
"""
_aq_reset()
class FieldValueInteractor(Interactor): class FieldValueInteractor(Interactor):
...@@ -117,7 +151,14 @@ class FieldValueInteractor(Interactor): ...@@ -117,7 +151,14 @@ class FieldValueInteractor(Interactor):
Installs interactions Installs interactions
""" """
from Products.Formulator.Field import ZMIField from Products.Formulator.Field import ZMIField
from Products.ERP5Form.ProxyField import ProxyField
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_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)
def uninstall(self): def uninstall(self):
""" """
...@@ -127,37 +168,10 @@ class FieldValueInteractor(Interactor): ...@@ -127,37 +168,10 @@ class FieldValueInteractor(Interactor):
def purgeFieldValueCache(self, method_call_object): def purgeFieldValueCache(self, method_call_object):
""" """
""" """
# here call something from Products.ERP5Form import Form, ProxyField
Form.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) # This is used in ERP5Form and install method is called in ERP5Form
#interactor_of_interactor.install() fielf_value_interactor = FieldValueInteractor()
\ No newline at end of file #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