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