Commit 1e2afbe9 authored by Kevin Deldycke's avatar Kevin Deldycke

Properties exported to an XML file are now sorted for easy diff.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3920 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 61c5987e
...@@ -385,40 +385,50 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -385,40 +385,50 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
""" """
f = StringIO() f = StringIO()
f.write('<?xml version="1.0"?>\n<SQLCatalogData>\n') f.write('<?xml version="1.0"?>\n<SQLCatalogData>\n')
id_list = self.propertyIds() property_id_list = self.propertyIds()
for id in id_list: # Get properties and values
value = self.getProperty(id) property_list = []
for property_id in property_id_list:
if value is None: value = self.getProperty(property_id)
# What is this? Not used? if value is not None:
continue property_list.append((property_id, value))
# Sort for easy diff
property_list.sort(lambda x, y: cmp(x[0], y[0]))
for property in property_list:
property_id = property[0]
value = property[1]
if type(value) == type(""): if type(value) == type(""):
f.write(' <property id=%s type="str">%s</property>\n' % (quoteattr(id), escape(value))) f.write(' <property id=%s type="str">%s</property>\n' % (quoteattr(property_id), escape(value)))
elif type(value) in (type(()), type([])): elif type(value) in (type(()), type([])):
f.write(' <property id=%s type="tuple">\n' % quoteattr(id)) f.write(' <property id=%s type="tuple">\n' % quoteattr(property_id))
# Sort for easy diff
item_list = []
for item in value: for item in value:
if type(item) in (type(""), type(u"")): if type(item) in (type(""), type(u"")):
item_list.append(item)
item_list.sort()
for item in item_list:
f.write(' <item type="str">%s</item>\n' % escape(str(item))) f.write(' <item type="str">%s</item>\n' % escape(str(item)))
else:
# Ignore the other types at the moment.
pass
f.write(' </property>\n') f.write(' </property>\n')
else:
# Ignore the other types at the moment.
pass
# XXX Although filters are not properties, output filters here. # XXX Although filters are not properties, output filters here.
# XXX Ideally, filters should be properties in Z SQL Methods, shouldn't they? # XXX Ideally, filters should be properties in Z SQL Methods, shouldn't they?
if hasattr(self, 'filter_dict'): if hasattr(self, 'filter_dict'):
for id in self.filter_dict.keys(): filter_list = []
filt = self.filter_dict[id] for filter_id in self.filter_dict.keys():
if not filt['filtered']: filter_definition = self.filter_dict[id]
filter_list.append((filter_id, filter_definition))
# Sort for easy diff
filter_list.sort(lambda x, y: cmp(x[0], y[0]))
for filter_item in filter_list:
filter_id = filter_item[0]
filter_def = filter_item[1]
if not filter_def['filtered']:
# If a filter is not activated, no need to output it. # If a filter is not activated, no need to output it.
continue continue
if not filt['expression']: if not filter_def['expression']:
# If the expression is not specified, meaningless to specify it. # If the expression is not specified, meaningless to specify it.
continue continue
f.write(' <filter id=%s expression=%s />\n' % (quoteattr(id), quoteattr(filt['expression']))) f.write(' <filter id=%s expression=%s />\n' % (quoteattr(filter_id), quoteattr(filter_def['expression'])))
# For now, portal types are not exported, because portal types are too specific to each site. # For now, portal types are not exported, because portal types are too specific to each site.
f.write('</SQLCatalogData>\n') f.write('</SQLCatalogData>\n')
......
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