Commit 74c171cd authored by Julien Muchembled's avatar Julien Muchembled

Small refactoring in BusinessTemplate.py

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43484 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ef922984
......@@ -812,16 +812,19 @@ class ObjectTemplateItem(BaseTemplateItem):
outfile.close()
raise
def getConnection(self, obj):
while True:
connection = obj._p_jar
if connection is not None:
return connection
obj = obj.aq_parent
def _importFile(self, file_name, file_obj):
# import xml file
if not file_name.endswith('.xml'):
LOG('Business Template', 0, 'Skipping file "%s"' % (file_name, ))
return
obj = self
connection = None
while connection is None:
obj=obj.aq_parent
connection=obj._p_jar
connection = self.getConnection(self.aq_parent)
__traceback_info__ = 'Importing %s' % file_name
if hasattr(cache_database, 'db') and isinstance(file_obj, file):
obj = connection.importFile(self._compileXML(file_obj))
......@@ -1126,11 +1129,7 @@ class ObjectTemplateItem(BaseTemplateItem):
# import sub objects if there is
if subobjects_dict:
# get a jar
connection = obj._p_jar
o = obj
while connection is None:
o = o.aq_parent
connection = o._p_jar
connection = self.getConnection(obj)
# import subobjects
for subobject_id, subobject_data in subobjects_dict.iteritems():
try:
......@@ -2696,11 +2695,7 @@ class CatalogMethodTemplateItem(ObjectTemplateItem):
self._method_properties.setdefault(id, PersistentMapping())[key] = 1
elif file_name.endswith('.xml'):
# just import xml object
obj = self
connection = None
while connection is None:
obj=obj.aq_parent
connection=obj._p_jar
connection = self.getConnection(self.aq_parent)
obj = connection.importFile(file, customImporters=customImporters)
self.removeProperties(obj, 0)
self._objects[file_name[:-4]] = obj
......
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