py2/py3: dict_key does not have sort().
... | @@ -1193,9 +1193,7 @@ class ObjectTemplateItem(BaseTemplateItem): | ... | @@ -1193,9 +1193,7 @@ class ObjectTemplateItem(BaseTemplateItem): |
def _getObjectKeyList(self): | def _getObjectKeyList(self): | ||
# sort to add objects before their subobjects | # sort to add objects before their subobjects | ||
keys = ensure_list(self._objects.keys()) | return sorted(self._objects.keys()) | ||
|
|||
keys.sort() | |||
return keys | |||
def unindexBrokenObject(self, item_path): | def unindexBrokenObject(self, item_path): | ||
""" | """ | ||
... | @@ -1673,11 +1671,9 @@ class PathTemplateItem(ObjectTemplateItem): | ... | @@ -1673,11 +1671,9 @@ class PathTemplateItem(ObjectTemplateItem): |
if object_path is not None: | if object_path is not None: | ||
object_keys = [object_path] | object_keys = [object_path] | ||
else: | else: | ||
object_keys = ensure_list(self._path_archive.keys()) | object_keys = self._path_archive.keys() | ||
object_keys.sort() | |||
object_keys.reverse() | |||
p = context.getPortalObject() | p = context.getPortalObject() | ||
for path in object_keys: | for path in sorted(object_keys, reverse=True): | ||
try: | try: | ||
path_list = self._resolvePath(p, [], path.split('/')) | path_list = self._resolvePath(p, [], path.split('/')) | ||
except AttributeError: | except AttributeError: | ||
... | @@ -1728,9 +1724,7 @@ class PathTemplateItem(ObjectTemplateItem): | ... | @@ -1728,9 +1724,7 @@ class PathTemplateItem(ObjectTemplateItem): |
def build(self, context, **kw): | def build(self, context, **kw): | ||
BaseTemplateItem.build(self, context, **kw) | BaseTemplateItem.build(self, context, **kw) | ||
p = context.getPortalObject() | p = context.getPortalObject() | ||
keys = ensure_list(self._path_archive.keys()) | for path in sorted(self._path_archive.keys()): | ||
|
|||
keys.sort() | |||
for path in keys: | |||
include_subobjects = 0 | include_subobjects = 0 | ||
if path.endswith("**"): | if path.endswith("**"): | ||
include_subobjects = 1 | include_subobjects = 1 | ||
... | @@ -2081,14 +2075,11 @@ class RegisteredSkinSelectionTemplateItem(BaseTemplateItem): | ... | @@ -2081,14 +2075,11 @@ class RegisteredSkinSelectionTemplateItem(BaseTemplateItem): |
# Function to generate XML Code Manually | # Function to generate XML Code Manually | ||
def generateXml(self, path=None): | def generateXml(self, path=None): | ||
xml_data = '<registered_skin_selection>' | xml_data = '<registered_skin_selection>' | ||
keys = ensure_list(self._objects.keys()) | for key in sorted(self._objects.keys()): | ||
|
|||
keys.sort() | |||
for key in keys: | |||
skin_selection_list = self._objects[key] | |||
xml_data += '\n <skin_folder_selection>' | xml_data += '\n <skin_folder_selection>' | ||
xml_data += '\n <skin_folder>%s</skin_folder>' % key | xml_data += '\n <skin_folder>%s</skin_folder>' % key | ||
xml_data += '\n <skin_selection>%s</skin_selection>' \ | xml_data += '\n <skin_selection>%s</skin_selection>' \ | ||
% ','.join(sorted(skin_selection_list)) | % ','.join(sorted(self._objects[key])) | ||
xml_data += '\n </skin_folder_selection>' | xml_data += '\n </skin_folder_selection>' | ||
xml_data += '\n</registered_skin_selection>' | xml_data += '\n</registered_skin_selection>' | ||
return xml_data | return xml_data | ||
... | @@ -2459,7 +2450,7 @@ class PortalTypeTemplateItem(ObjectTemplateItem): | ... | @@ -2459,7 +2450,7 @@ class PortalTypeTemplateItem(ObjectTemplateItem): |
def _getObjectKeyList(self): | def _getObjectKeyList(self): | ||
# Sort portal types to install according to their dependencies | # Sort portal types to install according to their dependencies | ||
object_key_list = ensure_list(self._objects.keys()) | object_key_list = self._objects.keys() | ||
path_dict = dict(x.split('/')[1:] + [x] for x in object_key_list) | path_dict = dict(x.split('/')[1:] + [x] for x in object_key_list) | ||
cache = {} | cache = {} | ||
def solveDependency(path): | def solveDependency(path): | ||
... | @@ -2480,8 +2471,7 @@ class PortalTypeTemplateItem(ObjectTemplateItem): | ... | @@ -2480,8 +2471,7 @@ class PortalTypeTemplateItem(ObjectTemplateItem): |
return 0, path | return 0, path | ||
cache[path] = score = depend and 1 + solveDependency(depend)[0] or 0 | cache[path] = score = depend and 1 + solveDependency(depend)[0] or 0 | ||
return score, path | return score, path | ||
object_key_list.sort(key=solveDependency) | return sorted(object_key_list, key=solveDependency) | ||
return object_key_list | |||
# XXX : this method is kept temporarily, but can be removed once all bt5 are | # XXX : this method is kept temporarily, but can be removed once all bt5 are | ||
# re-exported with separated workflow-chain information | # re-exported with separated workflow-chain information | ||
... | @@ -2561,14 +2551,11 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): | ... | @@ -2561,14 +2551,11 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): |
# Function to generate XML Code Manually | # Function to generate XML Code Manually | ||
def generateXml(self, path=None): | def generateXml(self, path=None): | ||
xml_data = '<workflow_chain>' | xml_data = '<workflow_chain>' | ||
key_list = ensure_list(self._objects.keys()) | for key in sorted(self._objects.keys()): | ||
|
|||
key_list.sort() | |||
for key in key_list: | |||
workflow_list = self._objects[key] | |||
xml_data += '\n <chain>' | xml_data += '\n <chain>' | ||
xml_data += '\n <type>%s</type>' %(key,) | xml_data += '\n <type>%s</type>' %(key,) | ||
xml_data += '\n <workflow>%s</workflow>' %( | xml_data += '\n <workflow>%s</workflow>' %( | ||
self._chain_string_separator.join(sorted(workflow_list))) | self._chain_string_separator.join(sorted(self._objects[key]))) | ||
xml_data += '\n </chain>' | xml_data += '\n </chain>' | ||
xml_data += '\n</workflow_chain>' | xml_data += '\n</workflow_chain>' | ||
return xml_data | return xml_data | ||
... | @@ -2778,9 +2765,7 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem): | ... | @@ -2778,9 +2765,7 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem): |
# Function to generate XML Code Manually | # Function to generate XML Code Manually | ||
def generateXml(self, path=None): | def generateXml(self, path=None): | ||
xml_data = '<%s>' %(self.xml_tag,) | xml_data = '<%s>' %(self.xml_tag,) | ||
key_list = ensure_list(self._objects.keys()) | for key in sorted(self._objects.keys()): | ||
|
|||
key_list.sort() | |||
for key in key_list: | |||
id_value = key.replace('%s/' % self.class_property, '') | id_value = key.replace('%s/' % self.class_property, '') | ||
allowed_item_list = sorted(self._objects[key]) | allowed_item_list = sorted(self._objects[key]) | ||
xml_data += '\n <portal_type id="%s">' % (id_value) | xml_data += '\n <portal_type id="%s">' % (id_value) | ||
... | @@ -3668,9 +3653,7 @@ class SitePropertyTemplateItem(BaseTemplateItem): | ... | @@ -3668,9 +3653,7 @@ class SitePropertyTemplateItem(BaseTemplateItem): |
if len(self._objects) == 0: | if len(self._objects) == 0: | ||
return | return | ||
xml_data = '<site_property>' | xml_data = '<site_property>' | ||
keys = ensure_list(self._objects.keys()) | for path in sorted(self._objects.keys()): | ||
|
|||
keys.sort() | |||
for path in keys: | |||
xml_data += self.generateXml(path) | xml_data += self.generateXml(path) | ||
xml_data += '\n</site_property>' | xml_data += '\n</site_property>' | ||
bta.addObject(xml_data, name='properties', path=self.__class__.__name__) | bta.addObject(xml_data, name='properties', path=self.__class__.__name__) | ||
... | @@ -3736,9 +3719,7 @@ class ModuleTemplateItem(BaseTemplateItem): | ... | @@ -3736,9 +3719,7 @@ class ModuleTemplateItem(BaseTemplateItem): |
if len(self._objects) == 0: | if len(self._objects) == 0: | ||
return | return | ||
path = self.__class__.__name__ | path = self.__class__.__name__ | ||
keys = ensure_list(self._objects.keys()) | for key in sorted(self._objects.keys()): | ||
|
|||
keys.sort() | |||
for key in keys: | |||
# export modules one by one | # export modules one by one | ||
xml_data = self.generateXml(path=key) | xml_data = self.generateXml(path=key) | ||
bta.addObject(xml_data, name=key, path=path) | bta.addObject(xml_data, name=key, path=path) | ||
... | ... |
... | @@ -36,11 +36,10 @@ else: | ... | @@ -36,11 +36,10 @@ else: |
modified_object_list = getModifiedObjectList(bt1, bt2) | modified_object_list = getModifiedObjectList(bt1, bt2) | ||
keys = modified_object_list.keys() | keys = modified_object_list.keys() | ||
keys.sort() | |||
i = 0 | i = 0 | ||
object_list = [] | object_list = [] | ||
for object_id in keys: | for object_id in sorted(keys): | ||
|
|||
object_state, object_class = modified_object_list[object_id] | object_state, object_class = modified_object_list[object_id] | ||
line = newTempBase(context, 'tmp_install_%s' %(str(i))) | line = newTempBase(context, 'tmp_install_%s' %(str(i))) | ||
line.edit(object_id=object_id, object_state=object_state, object_class=object_class, bt1=bt1.getId(), bt2=bt2.getId()) | line.edit(object_id=object_id, object_state=object_state, object_class=object_class, bt1=bt1.getId(), bt2=bt2.getId()) | ||
... | ... |