From 655ee64038372363c9e84fd636d82132c28827ad Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine <arnaud.fontaine@nexedi.com> Date: Wed, 22 Feb 2012 19:00:49 +0900 Subject: [PATCH] When importing from filesystem, do not check whether the source code is syntactically correct. Errors may occur if in the same transaction a Component is created and another one depending upon the former... --- product/ERP5Type/mixin/component.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/product/ERP5Type/mixin/component.py b/product/ERP5Type/mixin/component.py index 3219d268d6..a3d9ecb1dc 100644 --- a/product/ERP5Type/mixin/component.py +++ b/product/ERP5Type/mixin/component.py @@ -222,16 +222,18 @@ class ComponentMixin(Base): with open(path) as f: source_code = f.read() - # Try to load it first - namespace_dict = {} - exec source_code in namespace_dict - + # Checking that the source code is syntactically correct is not + # needed when importing from filesystem, moreover errors may occur + # if in the same transaction a Component is created and another + # one depending upon the former... new_component = context.newContent(id=object_id, reference=reference, version=version, text_content=source_code, portal_type=cls.portal_type) + # Validate the Component once it is imported so it can be used + # straightaway as there should be no error new_component.validate() # XXX-arnau: is it really safe? -- 2.30.9