Commit c5f8edc8 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Fix import of a file for DocumentTemplateItem for filesystem Document and Extension.

Also, set _archive properly for ZODB Document and Extension.
parent dfee694f
...@@ -3798,17 +3798,28 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem): ...@@ -3798,17 +3798,28 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem):
"%s.py" % class_id) "%s.py" % class_id)
def _importFile(self, file_name, file_obj): def _importFile(self, file_name, file_obj):
if (file_name.endswith('.py') and if file_name.endswith('.py'):
file_obj.name.rsplit(os.path.sep, 2)[-2] == 'portal_components'): # If portal_components/XXX.py, then ignore it as it will be handled when
return # the .xml file will be processed
if file_obj.name.rsplit(os.path.sep, 2)[-2] != 'portal_components':
FilesystemToZodbTemplateItem._importFile(self, file_name, file_obj) return FilesystemDocumentTemplateItem._importFile(self, file_name,
file_obj)
else:
ObjectTemplateItem._importFile(self, file_name, file_obj)
if file_name.endswith('.xml'): name = file_name[:-4]
obj = self._objects[file_name[:-4]] obj = self._objects[name]
with open("%s.py" % file_obj.name[:-4]) as f: with open("%s.py" % file_obj.name[:-4]) as f:
obj.text_content = f.read() obj.text_content = f.read()
# When importing a Business Template, there is no way to determine if it
# has been already migrated or not in __init__() when it does not
# already exist, therefore BaseTemplateItem.__init__() is called which
# does not set _archive with portal_components/ like
# ObjectTemplateItem.__init__()
self._archive[name] = None
del self._archive[name.replace('portal_components/', '')]
def export(self, context, bta, **kw): def export(self, context, bta, **kw):
path = self.__class__.__name__ + '/' path = self.__class__.__name__ + '/'
for key, obj in self._objects.iteritems(): for key, obj in self._objects.iteritems():
......
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