Commit e2a3cc40 authored by Aurel's avatar Aurel

separate generation of xml from export


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4327 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a8068efc
......@@ -1352,17 +1352,9 @@ class SitePropertyTemplateItem(BaseTemplateItem):
p._delProperty(id)
BaseTemplateItem.uninstall(self, context, **kw)
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
root_path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(name=root_path)
xml_data = '<site_property>'
keys = self._objects.keys()
keys.sort()
for path in keys:
def generate_xml(self, path=None):
xml_data = ''
type, object=self._objects[path]
# save it as xml
xml_data += os.linesep+' <property>'
xml_data += os.linesep+' <id>%s</id>' %(path,)
xml_data += os.linesep+' <type>%s</type>' %(type,)
......@@ -1375,6 +1367,18 @@ class SitePropertyTemplateItem(BaseTemplateItem):
else:
xml_data += os.linesep+' <value>%r</value>' %((os.linesep).join(object),)
xml_data += os.linesep+' </property>'
return xml_data
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
root_path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(name=root_path)
xml_data = '<site_property>'
keys = self._objects.keys()
keys.sort()
for path in keys:
xml_data += self.generate_xml(path)
xml_data += os.linesep+'</site_property>'
bta.addObject(object=xml_data, name='properties', path=root_path)
......@@ -1397,15 +1401,8 @@ class ModuleTemplateItem(BaseTemplateItem):
dict['permission_list'] = module.showPermissions()
self._objects[id] = dict
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(path)
keys = self._objects.keys()
keys.sort()
for id in keys:
dict = self._objects[id]
def generate_xml(self, path=None):
dict = self._objects[path]
xml_data = '<module>'
for key in dict.keys():
if key =='permission_list':
......@@ -1423,6 +1420,18 @@ class ModuleTemplateItem(BaseTemplateItem):
else:
xml_data += os.linesep+' <%s>%s</%s>' %(key, dict[key], key)
xml_data += os.linesep+'</module>'
return xml_data
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(path)
keys = self._objects.keys()
keys.sort()
for id in keys:
# expor module one by one
xml_data = self.generate_xml(path=id)
bta.addObject(object=xml_data, name=id, path=path)
def install(self, context, **kw):
......@@ -1620,17 +1629,21 @@ class RoleTemplateItem(BaseTemplateItem):
del roles[role]
p.__ac_roles__ = tuple(roles.keys())
def generate_xml(self, path):
object=self._objects[path]
xml_data = '<role_list>'
for role in object:
xml_data += os.linesep+' <role>%s</role>' %(role)
xml_data += os.linesep+'</role_list>'
return xml_data
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(name=path)
for path in self._objects.keys():
object=self._objects[path]
xml_data = '<role_list>'
for role in object:
xml_data += os.linesep+' <role>%s</role>' %(role)
xml_data += os.linesep+'</role_list>'
xml_data = self.generate_xml(path=path)
bta.addObject(object=xml_data, name=path, path=None,)
class CatalogResultKeyTemplateItem(BaseTemplateItem):
......@@ -1702,17 +1715,21 @@ class CatalogResultKeyTemplateItem(BaseTemplateItem):
catalog.sql_search_result_keys = sql_search_result_keys
BaseTemplateItem.uninstall(self, context, **kw)
def generate_xml(self, path=None):
object=self._objects[path]
xml_data = '<key_list>'
for key in object:
xml_data += os.linesep+' <key>%s</key>' %(key)
xml_data += os.linesep+'</key_list>'
return xml_data
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(name=path)
for path in self._objects.keys():
object=self._objects[path]
xml_data = '<key_list>'
for key in object:
xml_data += os.linesep+' <key>%s</key>' %(key)
xml_data += os.linesep+'</key_list>'
xml_data = self.generate_xml(path=path)
bta.addObject(object=xml_data, name=path, path=None)
class CatalogRelatedKeyTemplateItem(BaseTemplateItem):
......@@ -1783,17 +1800,21 @@ class CatalogRelatedKeyTemplateItem(BaseTemplateItem):
catalog.sql_catalog_related_keys = sql_catalog_related_keys
BaseTemplateItem.uninstall(self, context, **kw)
def generate_xml(self, path=None):
object=self._objects[path]
xml_data = '<key_list>'
for key in object:
xml_data += os.linesep+' <key>%s</key>' %(key)
xml_data += os.linesep+'</key_list>'
return xml_data
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(name=path)
for path in self._objects.keys():
object=self._objects[path]
xml_data = '<key_list>'
for key in object:
xml_data += os.linesep+' <key>%s</key>' %(key)
xml_data += os.linesep+'</key_list>'
xml_data = self.generate_xml(path=path)
bta.addObject(object=xml_data, name=path, path=None)
class CatalogResultTableTemplateItem(BaseTemplateItem):
......@@ -1864,17 +1885,21 @@ class CatalogResultTableTemplateItem(BaseTemplateItem):
catalog.sql_search_tables = sql_search_tables
BaseTemplateItem.uninstall(self, context, **kw)
def generate_xml(self, path=None):
object=self._objects[path]
xml_data = '<key_list>'
for key in object:
xml_data += os.linesep+' <key>%s</key>' %(key)
xml_data += os.linesep+'</key_list>'
return xml_data
def export(self, context, bta, **kw):
if len(self._objects.keys()) == 0:
return
path = os.path.join(bta.path, self.__class__.__name__)
bta.addFolder(name=path)
for path in self._objects.keys():
object=self._objects[path]
xml_data = '<key_list>'
for key in object:
xml_data += os.linesep+' <key>%s</key>' %(key)
xml_data += os.linesep+'</key_list>'
xml_data = self.generate_xml(path=path)
bta.addObject(object=xml_data, name=path, path=None)
class MessageTranslationTemplateItem(BaseTemplateItem):
......
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