Commit 09244a48 authored by Aurel's avatar Aurel

define export method on ObjectTemplateItem and not on BaseTemplateItem


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4125 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e92b969b
...@@ -256,19 +256,7 @@ class BaseTemplateItem(Implicit, Persistent): ...@@ -256,19 +256,7 @@ class BaseTemplateItem(Implicit, Persistent):
return '' return ''
def export(self, context, bta, **kw): def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0: pass
return
root_path = os.path.join(bta.path, self.__class__.__name__)
for key in self._objects.keys():
object=self._objects[key]
# create folder and subfolders
folders, id = os.path.split(key)
path = os.path.join(root_path, folders)
bta.addFolder(name=path)
# export object in xml
f=StringIO()
XMLExportImport.exportXML(object._p_jar, object._p_oid, f)
bta.addObject(object=f.getvalue(), name=id, path=path)
def importFile(self, bta, **kw): def importFile(self, bta, **kw):
bta.importFiles(klass=self) bta.importFiles(klass=self)
...@@ -286,6 +274,21 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -286,6 +274,21 @@ class ObjectTemplateItem(BaseTemplateItem):
for id in id_list: for id in id_list:
self._archive["%s/%s" % (tool_id, id)] = None self._archive["%s/%s" % (tool_id, id)] = None
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
root_path = os.path.join(bta.path, self.__class__.__name__)
for key in self._objects.keys():
object=self._objects[key]
# create folder and subfolders
folders, id = os.path.split(key)
path = os.path.join(root_path, folders)
bta.addFolder(name=path)
# export object in xml
f=StringIO()
XMLExportImport.exportXML(object._p_jar, object._p_oid, f)
bta.addObject(object=f.getvalue(), name=id, path=path)
def build_sub_objects(self, context, id_list, url, **kw): def build_sub_objects(self, context, id_list, url, **kw):
p = context.getPortalObject() p = context.getPortalObject()
sub_list = {} sub_list = {}
...@@ -1818,8 +1821,8 @@ class MessageTranslationTemplateItem(BaseTemplateItem): ...@@ -1818,8 +1821,8 @@ class MessageTranslationTemplateItem(BaseTemplateItem):
self._objects[path] = mc.manage_export(lang) self._objects[path] = mc.manage_export(lang)
def install(self, context, **kw): def install(self, context, **kw):
localizer = context.getPortalObject().Localizer
if (getattr(self, 'template_format_version', 0)) == 1: if (getattr(self, 'template_format_version', 0)) == 1:
localizer = context.getPortalObject().Localizer
for path, po in self._objects.items(): for path, po in self._objects.items():
path = string.split(path, '/') path = string.split(path, '/')
lang = path[-3] lang = path[-3]
...@@ -1832,7 +1835,6 @@ class MessageTranslationTemplateItem(BaseTemplateItem): ...@@ -1832,7 +1835,6 @@ class MessageTranslationTemplateItem(BaseTemplateItem):
mc.manage_import(lang, po) mc.manage_import(lang, po)
else: else:
BaseTemplateItem.install(self, context, **kw) BaseTemplateItem.install(self, context, **kw)
localizer = context.getPortalObject().Localizer
for lang, catalogs in self._archive.items(): for lang, catalogs in self._archive.items():
if lang not in localizer.get_languages(): if lang not in localizer.get_languages():
localizer.manage_addLanguage(lang) localizer.manage_addLanguage(lang)
......
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