Commit 655ee640 authored by Arnaud Fontaine's avatar Arnaud Fontaine

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...
parent 801a347e
...@@ -222,16 +222,18 @@ class ComponentMixin(Base): ...@@ -222,16 +222,18 @@ class ComponentMixin(Base):
with open(path) as f: with open(path) as f:
source_code = f.read() source_code = f.read()
# Try to load it first # Checking that the source code is syntactically correct is not
namespace_dict = {} # needed when importing from filesystem, moreover errors may occur
exec source_code in namespace_dict # if in the same transaction a Component is created and another
# one depending upon the former...
new_component = context.newContent(id=object_id, new_component = context.newContent(id=object_id,
reference=reference, reference=reference,
version=version, version=version,
text_content=source_code, text_content=source_code,
portal_type=cls.portal_type) 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() new_component.validate()
# XXX-arnau: is it really safe? # XXX-arnau: is it really safe?
......
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