From 7a787cc43623e22e32a1ecb380b07d3d33f5cab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 21 Feb 2006 18:03:47 +0000 Subject: [PATCH] Add an external method to update the class of a persistent object. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5763 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Extensions/CheckPortalTypes.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/product/ERP5/Extensions/CheckPortalTypes.py b/product/ERP5/Extensions/CheckPortalTypes.py index 3f0d9e8e34..5199359ab0 100755 --- a/product/ERP5/Extensions/CheckPortalTypes.py +++ b/product/ERP5/Extensions/CheckPortalTypes.py @@ -10,3 +10,13 @@ def fixProductNames(self, REQUEST=None): msg += 'Change the Product Name of %s from %s to ERP5Type\n' % (contentType.getId(), contentType.product) contentType.product = 'ERP5Type' return msg + +def changeObjectClass(self, container, object_id, new_class): + """Creates a copy of object_id inside container, changing its class to + new_class""" + old_obj = container._getObj(object_id) + new_obj = new_class(object_id) + new_obj.__dict__.update(old_obj.__dict__) + container._setObject(object_id, new_obj) + + -- 2.30.9