Commit 126ae257 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! py2/py3: dict_key does not have sort().

parent c98ecf4a
This diff is collapsed.
......@@ -2,6 +2,7 @@
Generic method called when submitting a form in dialog mode.
Responsible for validating form data and redirecting to the form action.
"""
import six
# XXX We should not use meta_type properly,
# XXX We need to discuss this problem.(yusei)
......@@ -131,9 +132,8 @@ if len(listbox_id_list):
for listbox_id in listbox_id_list:
listbox_line_list = []
listbox = kw[listbox_id]
listbox_keys = listbox.keys()
for key in sorted(listbox_keys):
listbox_line = listbox[key]
for key, value in sorted(six.iteritems(listbox)):
listbox_line = value
listbox_line['listbox_key'] = key
listbox_line_list.append(listbox_line)
listbox_line_list = tuple(listbox_line_list)
......
......@@ -35,16 +35,12 @@ if p.portal_templates.compareVersions(bt1.getVersion(), bt2.getVersion()) < 0:
else:
modified_object_list = getModifiedObjectList(bt1, bt2)
keys = modified_object_list.keys()
i = 0
object_list = []
for object_id in sorted(keys):
object_state, object_class = modified_object_list[object_id]
for i, (object_id, value) in enumerate(sorted(six.iteritems(modified_object_list))):
Please register or sign in to reply
object_state, object_class = value
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.setUid('new_%s' % object_id)
object_list.append(line)
i += 1
return object_list
from Products.ERP5Type.Document import newTempBase
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.Utils import ensure_list
import six
Base_translateString = context.Base_translateString
def getModifiedObjectList(context):
......@@ -21,7 +22,6 @@ getModifiedObjectList = CachingMethod(getModifiedObjectList,
cache_id_generator=cache_id_generator)
modified_object_list = getModifiedObjectList(context)
keys = ensure_list(modified_object_list.keys())
no_backup_list = ['Action', 'SiteProperty', 'Module', 'Document',
'PropertySheet', 'Extension', 'Test', 'Product', 'Role',
......@@ -40,10 +40,9 @@ backup_title = Base_translateString('Backup And Upgrade')
remove_title = Base_translateString('Remove')
save_and_remove_title = Base_translateString('Backup And Remove')
i = 0
object_list = []
for object_id in sorted(keys):
object_state, object_class = modified_object_list[object_id]
for i, (object_id, value) in enumerate(sorted(six.iteritems(modified_object_list))):
object_state, object_class = value
line = newTempBase(context, 'tmp_install_%s' %(str(i)))
if object_state == 'New':
choice_item_list=[[install_title, 'install']]
......@@ -66,7 +65,6 @@ for object_id in sorted(keys):
choice_item_list=choice_item_list)
line.setUid('new_%s' % str(object_id))
object_list.append(line)
i += 1
object_list.sort(key=lambda x:(x.object_class, x.object_state))
return object_list
......@@ -19,7 +19,7 @@ if hasattr(request, listbox_id):
# initialize the listbox
listbox=request[listbox_id]
keys_list = sorted(listbox.keys(), key=int)
keys_list = sorted(listbox, key=int)
if keys_list != []:
first_empty_line_id = int(keys_list[-1])+1
......
import six
REQUEST = container.REQUEST
Base_translateString = context.Base_translateString
......@@ -45,8 +46,7 @@ save_and_remove_title = Base_translateString('Backup And Remove')
for bt in bt_id_list:
bt_title, modified_object_list = bt_object_dict[bt]
keys = modified_object_list.keys()
for i, object_id in enumerate(sorted(keys)):
for i, (object_id, value) in enumerate(sorted(six.iteritems(modified_object_list))):
object_state, object_class = modified_object_list[object_id]
object_id = bt+'|'+object_id
line = newTempBase(context, 'tmp_install_%s' % i)
......
......@@ -143,26 +143,24 @@ def Base_asXML(object, root=None):
# We have to describe the workflow history
if getattr(self, 'workflow_history', None) is not None:
workflow_list = self.workflow_history
workflow_list_keys = workflow_list.keys()
for workflow_id in sorted(workflow_list_keys): # Make sure it is sorted
for workflow_action in workflow_list[workflow_id]:
for workflow_id, workflow_action_list in sorted(six.iteritems(workflow_list)): # Make sure it is sorted
for workflow_action in workflow_action_list:
workflow_node = SubElement(object, 'workflow_action',
attrib=dict(workflow_id=workflow_id))
workflow_variable_list = workflow_action.keys()
for workflow_variable in sorted(workflow_variable_list):
for workflow_variable, variable_node_text in sorted(six.iteritems(workflow_action)):
variable_type = "string" # Somewhat bad, should find a better way
if workflow_variable.find('time') >= 0:
variable_type = "date"
if workflow_variable.find('language_revs') >= 0: # XXX specific to cps
variable_type = "dict"
if workflow_action[workflow_variable] is None:
if variable_node_text is None:
variable_type = 'None'
variable_node = SubElement(workflow_node, workflow_variable,
attrib=dict(type=variable_type))
if variable_type != 'None':
variable_node_text = str(workflow_action[workflow_variable])
variable_node.text = six.text_type(variable_node_text, 'utf-8')
variable_node.text = six.text_type(str(variable_node_text), 'utf-8')
if workflow_variable == 'time':
time = variable_node.text
......
......@@ -644,10 +644,8 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
return x
# Generate sorted msgids to simplify diffs
dkeys = d.keys()
for k in sorted(dkeys):
for k, v in sorted(six.iteritems(d)):
r.append('msgid "%s"' % backslashescape(k))
v = d[k]
r.append('msgstr "%s"' % backslashescape(v))
r.append('')
......
......@@ -118,8 +118,7 @@ class BaseMailTemplate:
# we want to have it stored in ERP5, for mail threading
headers['Message-ID'] = make_msgid()
# turn headers into an ordered list for predictable header order
keys = headers.keys()
return msg,values,[(key,headers[key]) for key in sorted(keys)]
return msg, values, [(key, value) for key, value in sorted(six.iteritems(headers))]
security.declarePrivate('_send')
def _send(self,mfrom,mto,msg):
......
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