Commit df59c6c6 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: ERP5Type: Avoid patching Portal Type in customer project for init_script...

WIP: ERP5Type: Avoid patching Portal Type in customer project for init_script (very common) by having an afterClone-like getTypeBasedMethod().
parent 8d3388d4
......@@ -3,7 +3,6 @@ for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lam
print " ", "\n ".join([x for x in (
"Short Title: %s" % ti.getShortTitle(),
"Class: %s" % ti.getTypeClass(),
"Init Script: %s" % ti.getTypeInitScriptId(),
"Add Permission: %s" % ti.getTypeAddPermission(),
"Acquire Local Roles: %s" % ti.getTypeAcquireLocalRole(),
"Property Sheets: %r" % sorted(ti.getTypePropertySheetList()),
......
......@@ -438,8 +438,13 @@ class ERP5TypeInformation(XMLObject,
init_script = self.getTypeInitScriptId()
if init_script:
# Acquire the init script in the context of this object
deprecated("'type_init_script_id' deprecated in favor of getTypeBasedMethod()")
getattr(ob, init_script)(created_by_builder=created_by_builder,
edit_kw=kw)
else:
init_script = self._getTypeBasedMethod('init')
if init_script is not None and callable(init_script):
init_script(created_by_builder=created_by_builder, edit_kw=kw)
if kw:
ob._edit(force_update=1, **kw)
......@@ -654,8 +659,7 @@ class ERP5TypeInformation(XMLObject,
"""Return keywords for "Find" tab in ZMI"""
search_source_list = [self.getId(),
self.getTypeFactoryMethodId(),
self.getTypeAddPermission(),
self.getTypeInitScriptId()]
self.getTypeAddPermission()]
search_source_list += self.getTypePropertySheetList()
search_source_list += self.getTypeBaseCategoryList()
return ' '.join(filter(None, search_source_list))
......
......@@ -501,6 +501,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.portal.portal_caches.clearCache()
self.assertEqual(cache(), cached_var)
def test_07_initScript(self):
"""TODO: Similar to test_07_afterCloneScript"""
pass
def test_07_afterCloneScript(self):
"""manage_afterClone can call a type based script."""
# setup the script for Person portal type
......
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