Commit bed0bfd8 authored by Romain Courteaud's avatar Romain Courteaud

Add dynamic generation of forwarder methods.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2314 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2b6f66f8
...@@ -908,27 +908,38 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -908,27 +908,38 @@ class SelectionTool( UniqueObject, SimpleItem ):
# Return the search dialog # Return the search dialog
return o.Base_viewRelatedObjectList(REQUEST=REQUEST) return o.Base_viewRelatedObjectList(REQUEST=REQUEST)
# XXX Methods here should be generated dynamically instead each time
# _v_relation_field_index is increased def __getattr__(self, name):
security.declareProtected(ERP5Permissions.View, 'viewSearchRelatedDocumentDialog0') dynamic_method_name = 'viewSearchRelatedDocumentDialog'
def viewSearchRelatedDocumentDialog0(self, form_id, REQUEST=None, **kw): if name[:len(dynamic_method_name)] == dynamic_method_name:
"""Forwarder method""" method_count_string = name[len(dynamic_method_name):]
return self.viewSearchRelatedDocumentDialog(0, form_id, REQUEST=REQUEST, **kw) # be sure that method name is correct
try:
security.declareProtected(ERP5Permissions.View, 'viewSearchRelatedDocumentDialog1') import string
def viewSearchRelatedDocumentDialog1(self, form_id, REQUEST=None, **kw): method_count = string.atoi(method_count_string)
"""Forwarder method""" except:
return self.viewSearchRelatedDocumentDialog(1, form_id, REQUEST=REQUEST, **kw) raise AttributeError, name
else:
security.declareProtected(ERP5Permissions.View, 'viewSearchRelatedDocumentDialog2') # generate dynamicaly needed forwarder methods
def viewSearchRelatedDocumentDialog2(self, form_id, REQUEST=None, **kw): def viewSearchRelatedDocumentDialogWrapper(self, form_id, REQUEST=None, **kw):
"""Forwarder method""" """
return self.viewSearchRelatedDocumentDialog(2, form_id, REQUEST=REQUEST, **kw) viewSearchRelatedDocumentDialog Wrapper
"""
security.declareProtected(ERP5Permissions.View, 'viewSearchRelatedDocumentDialog9') return self.viewSearchRelatedDocumentDialog(method_count, form_id, REQUEST=REQUEST, **kw)
def viewSearchRelatedDocumentDialog9(self, form_id, REQUEST=None, **kw):
"""Forwarder method""" setattr(self.__class__, name, viewSearchRelatedDocumentDialogWrapper)
return self.viewSearchRelatedDocumentDialog(9, form_id, REQUEST=REQUEST, **kw)
klass = self.__class__
if hasattr(klass, 'security'):
from Products.ERP5Type import Permissions as ERP5Permissions
klass.security.declareProtected(ERP5Permissions.View, name)
else:
# XXX security declaration always failed....
LOG('WARNING ERP5Form SelectionTool, security not defined on',0,klass.__name__)
return getattr(self, name)
else:
raise AttributeError, name
InitializeClass( SelectionTool ) InitializeClass( SelectionTool )
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