Commit 24aff386 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP

parent aec66a49
This diff is collapsed.
......@@ -85,7 +85,7 @@ class SQLDict(SQLBase):
uid = line.uid
original_uid = path_and_method_id_dict.get(key)
if original_uid is None:
sql_method_id = " AND method_id = %s AND group_method_id = %s" % (
sql_method_id = b" AND method_id = %s AND group_method_id = %s" % (
quote(method_id), quote(line.group_method_id))
m = Message.load(line.message, uid=uid, line=line)
merge_parent = m.activity_kw.get('merge_parent')
......@@ -102,11 +102,11 @@ class SQLDict(SQLBase):
uid_list = []
if path_list:
# Select parent messages.
result = Results(db.query("SELECT * FROM message"
" WHERE processing_node IN (0, %s) AND path IN (%s)%s"
" ORDER BY path LIMIT 1 FOR UPDATE" % (
result = Results(db.query(b"SELECT * FROM message"
b" WHERE processing_node IN (0, %d) AND path IN (%s)%s"
b" ORDER BY path LIMIT 1 FOR UPDATE" % (
processing_node,
','.join(map(quote, path_list)),
b','.join(map(quote, path_list)),
sql_method_id,
), 0))
if result: # found a parent
......@@ -119,11 +119,11 @@ class SQLDict(SQLBase):
m = Message.load(line.message, uid=uid, line=line)
# return unreserved similar children
path = line.path
result = db.query("SELECT uid FROM message"
" WHERE processing_node = 0 AND (path = %s OR path LIKE %s)"
"%s FOR UPDATE" % (
result = db.query(b"SELECT uid FROM message"
b" WHERE processing_node = 0 AND (path = %s OR path LIKE %s)"
b"%s FOR UPDATE" % (
quote(path), quote(path.replace('_', r'\_') + '/%'),
sql_method_id,
sql_method_id.encode(),
), 0)[1]
reserve_uid_list = [x for x, in result]
uid_list += reserve_uid_list
......@@ -132,8 +132,8 @@ class SQLDict(SQLBase):
reserve_uid_list.append(uid)
else:
# Select duplicates.
result = db.query("SELECT uid FROM message"
" WHERE processing_node = 0 AND path = %s%s FOR UPDATE" % (
result = db.query(b"SELECT uid FROM message"
b" WHERE processing_node = 0 AND path = %s%s FOR UPDATE" % (
quote(path), sql_method_id,
), 0)[1]
reserve_uid_list = uid_list = [x for x, in result]
......
......@@ -1356,7 +1356,7 @@ class ActivityTool (BaseTool):
# use a round-robin algorithm.
# XXX: We always finish by iterating over all queues, in case that
# getPriority does not see messages dequeueMessage would process.
activity_list = activity_dict.values()
activity_list = list(activity_dict.values())
def sort_key(activity):
return activity.getPriority(self, processing_node,
node_family_id_set)
......@@ -1390,7 +1390,7 @@ class ActivityTool (BaseTool):
path = None if obj is None else '/'.join(obj.getPhysicalPath())
db = self.getSQLConnection()
quote = db.string_literal
return bool(db.query("(%s)" % ") UNION ALL (".join(
return bool(db.query(b"(%s)" % b") UNION ALL (".join(
activity.hasActivitySQL(quote, path=path, **kw)
for activity in activity_dict.itervalues()))[1])
......
......@@ -118,7 +118,7 @@ class Balancer:
if addr not in self.disabled_server_dict:
count_dict[addr] = 0
expired_server_list = []
for key,value in self.sticked_server_dict.items():
for key,value in list(self.sticked_server_dict.items()):
if self.debug:
print('cur_time = %f, value.atime = %f' % (cur_time, value.atime))
if cur_time > value.atime + 60 * 10:
......
......@@ -75,7 +75,7 @@ class Filter(Implicit):
return False
if self.filter_leave and not self._isNode(context):
return False
for k, v in self.filter_dict.items():
for k, v in list(self.filter_dict.items()):
if type(v) in (type([]), type(())):
if context.getProperty(k) not in v:
return False
......
......@@ -114,6 +114,7 @@ def match(self, request):
return 1
else:
return 0
from ZServer.HTTPServer import zhttp_handler
zhttp_handler.match = match
import six
if six.PY2:
from ZServer.HTTPServer import zhttp_handler
zhttp_handler.match = match
This diff is collapsed.
......@@ -197,7 +197,7 @@ class SQLNonContinuousIncreasingIdGenerator(IdGenerator):
if not (self.last_max_id_dict or
getattr(portal_ids, 'dict_length_ids', None) is None):
dump_dict = portal_ids.dict_length_ids
for id_group, last_id in dump_dict.items():
for id_group, last_id in list(dump_dict.items()):
last_insert_id = get_last_id_method(id_group=id_group)
last_id = int(last_id.value)
if len(last_insert_id) != 0:
......@@ -261,7 +261,7 @@ class SQLNonContinuousIncreasingIdGenerator(IdGenerator):
if not isinstance(id_dict, dict):
raise TypeError('the argument given is not a dictionary')
new_id_dict = {}
for key, value in id_dict.items():
for key, value in list(id_dict.items()):
if isinstance(value, int):
set_last_id_method(id_group=key, last_id=value)
# The id must be a ScalarMaxConflictResolver object for the persistent dict
......
......@@ -82,7 +82,7 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation):
# Default Implementation (use categories and trivial case)
# this default implementation should be applicable to most
# solvers so that use of Type Based methods is very rare
for solver, configuration_list in movement_dict[movement].items():
for solver, configuration_list in list(movement_dict[movement].items()):
if solver is not self and solver.getTestedProperty() == self.getTestedProperty():
return AppropriateUIMessage(whatever) # XXX-TODO
......
......@@ -95,8 +95,8 @@ class StringAttributeMatchConstraint(PropertyExistenceConstraint):
'title' : '^[^ ]'
}
"""
property_list = property_dict.keys()
regex_list = property_dict.values()
property_list = list(property_dict.keys())
regex_list = list(property_dict.values())
regex_list_len = len(regex_list)
seen_property_set = set()
for property_index, property_id in enumerate(property_list):
......
......@@ -107,7 +107,7 @@ class ZODBContinuousIncreasingIdGenerator(IdGenerator):
portal_ids = getattr(self, 'portal_ids', None)
# Dump the dict_ids dictionary
if getattr(portal_ids, 'dict_ids', None) is not None:
for id_group, last_id in portal_ids.dict_ids.items():
for id_group, last_id in list(portal_ids.dict_ids.items()):
if not isinstance(id_group, str):
id_group = repr(id_group)
if id_group in self.last_id_dict and \
......
......@@ -46,6 +46,7 @@ from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModule
from Products.ERP5Type.mixin.response_header_generator import ResponseHeaderGenerator
from zLOG import LOG, INFO, WARNING, ERROR
from zExceptions import BadRequest
import os
import warnings
import transaction
......@@ -2267,7 +2268,10 @@ class ERP5Generator(PortalGenerator):
workflow_list = ['business_template_building_workflow',
'business_template_installation_workflow']
tool = p.portal_workflow
tool.manage_delObjects(filter(tool.hasObject, workflow_list))
try:
tool.manage_delObjects(list(filter(tool.hasObject, workflow_list)))
except BadRequest:
pass
self.bootstrap(tool, 'erp5_core', 'WorkflowTemplateItem', workflow_list)
getattr(p.portal_types, 'Business Template').setTypeWorkflowList(workflow_list)
......
......@@ -206,7 +206,7 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionValueList')
def getTransitionValueList(self):
if self.interactions is not None:
return self.interactions.values()
return list(self.interactions.values())
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getTransitionReferenceList')
......@@ -218,7 +218,7 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
security.declareProtected(Permissions.AccessContentsInformation, 'getVariableValueList')
def getVariableValueList(self):
if self.variables is not None:
return self.variables.values()
return list(self.variables.values())
return []
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalType')
......
......@@ -48,8 +48,8 @@ class PortalTypeClassInteractor(Interactor):
self.on(Variables.setStateVar).doAfter(self.resetDynamic)
from Products.Localizer.Localizer import Localizer
self.on(Localizer.add_language).doAfter(self.resetDynamic)
self.on(Localizer.del_language).doAfter(self.resetDynamic)
self.on(Localizer, 'add_language').doAfter(self.resetDynamic)
self.on(Localizer, 'del_language').doAfter(self.resetDynamic)
def resetDynamic(self, method_call_object, *args, **kw):
"""
......
......@@ -113,7 +113,7 @@ class CopyToTarget(TargetSolver):
parent_movement = None
for date_delta in ('start_date_delta', 'stop_date_delta'):
if date_delta in value_delta_dict.keys():
if date_delta in list(value_delta_dict.keys()):
if abs(value_delta_dict[date_delta]) <= \
applied_rule.getProperty('max_allowed_delta', max_allowed_delta):
value_delta_dict.pop(date_delta)
......
......@@ -167,6 +167,7 @@ class AlarmTool(TimerServiceMixin, BaseTool):
# only start when we are the alarmNode
alarmNode = self.getAlarmNode()
current_node = getCurrentNode()
global _check_upgrade
if alarmNode == '':
self.setAlarmNode(current_node)
alarmNode = current_node
......@@ -179,7 +180,6 @@ class AlarmTool(TimerServiceMixin, BaseTool):
elif _check_upgrade and self.getServerAddress() == alarmNode:
# BBB: check (once per run) if our node was alarm_node by address, and
# migrate it.
global _check_upgrade
_check_upgrade = False
self.setAlarmNode(current_node)
finally:
......
......@@ -93,7 +93,8 @@ class IdTool(BaseTool):
version_last_generator = 0
for generator in self.objectValues():
if generator.getReference() == reference:
version = generator.getVersion()
# Version Property Sheet defines 'version' property as a 'string'
version = int(generator.getVersion())
if version > version_last_generator:
id_last_generator = generator.getId()
version_last_generator = version
......@@ -366,7 +367,7 @@ class IdTool(BaseTool):
"""
if getattr(self, 'dict_length_ids', None) is None:
self.dict_length_ids = PersistentMapping()
return self.dict_length_ids.items()
return list(self.dict_length_ids.items())
security.declarePrivate('dumpDictLengthIdsItems')
def dumpDictLengthIdsItems(self):
......
......@@ -27,7 +27,9 @@
#
##############################################################################
from webdav.client import Resource
## XXX: WebDAV client implementation from ZServer
##from webdav.client import Resource
from past.builtins import cmp
from App.config import getConfiguration
......@@ -701,7 +703,7 @@ class TemplateTool (BaseTool):
"""
Get the list of repositories.
"""
return self.repository_dict.keys()
return list(self.repository_dict.keys())
security.declarePublic( 'decodeRepositoryBusinessTemplateUid' )
def decodeRepositoryBusinessTemplateUid(self, uid):
......@@ -775,7 +777,7 @@ class TemplateTool (BaseTool):
tuple (repository, id)
"""
result = None
for repository, property_dict_list in self.repository_dict.items():
for repository, property_dict_list in list(self.repository_dict.items()):
for property_dict in property_dict_list:
provision_list = property_dict.get('provision_list', [])
if title in provision_list:
......@@ -797,7 +799,7 @@ class TemplateTool (BaseTool):
the given business template
"""
result_list = []
for repository, property_dict_list in self.repository_dict.items():
for repository, property_dict_list in list(self.repository_dict.items()):
for property_dict in property_dict_list:
provision_list = property_dict['provision_list']
if (title in provision_list) and (property_dict['title'] not in result_list):
......@@ -817,7 +819,7 @@ class TemplateTool (BaseTool):
# for meta business templates
if bt[0] != 'meta':
result_list = []
for repository, property_dict_list in self.repository_dict.items():
for repository, property_dict_list in list(self.repository_dict.items()):
if repository == bt[0]:
for property_dict in property_dict_list:
if property_dict['id'] == bt[1]:
......@@ -910,7 +912,7 @@ class TemplateTool (BaseTool):
# Calculate the reverse dependency graph
reverse_dependency_dict = {}
for bt_id, dependency_id_list in dependency_dict.items():
for bt_id, dependency_id_list in list(dependency_dict.items()):
update_dependency_id_list = []
for dependency_id in dependency_id_list:
......@@ -1001,7 +1003,7 @@ class TemplateTool (BaseTool):
template_item_list = []
# First of all, filter Business Templates in repositories.
template_item_dict = {}
for repository, property_dict_list in self.repository_dict.items():
for repository, property_dict_list in list(self.repository_dict.items()):
for property_dict in property_dict_list:
title = property_dict['title']
if template_set and not(title in template_set):
......@@ -1023,7 +1025,7 @@ class TemplateTool (BaseTool):
template_item_dict[title] = (repository, property_dict)
# Next, select only updated business templates.
if update_only:
for repository, property_dict in template_item_dict.values():
for repository, property_dict in list(template_item_dict.values()):
installed_bt = \
self.getInstalledBusinessTemplate(property_dict['title'], strict=True)
if installed_bt is not None:
......
......@@ -171,8 +171,13 @@ def runwsgi():
make_wsgi_app({}, zope_conf=args.zope_conf)
from Signals.SignalHandler import SignalHandler
SignalHandler.registerHandler(signal.SIGTERM, sys.exit)
try:
from Signals.SignalHandler import SignalHandler
except ImportError:
# XXX-zope4py3: TODO
pass
else:
SignalHandler.registerHandler(signal.SIGTERM, sys.exit)
if args.timerserver_interval:
import Products.TimerService
......
......@@ -299,7 +299,7 @@ class Amount(Base, VariatedMixin):
variation_list = resource.getVariationPropertyList()
else:
variation_list = []
for property_id, property_value in property_dict.items():
for property_id, property_value in list(property_dict.items()):
if property_id not in variation_list:
raise KeyError("Can not set the property variation %r" % property_id)
else:
......
......@@ -246,7 +246,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
if sm_list:
r.setdefault(x.getSpecialise(), []).append(sm_list)
# For each rule...
for x in r.values():
for x in list(r.values()):
if len(x) > 1:
# There were several AR applying the same rule.
# Choose the one with a built SM (it will fail if
......@@ -316,7 +316,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
try:
best_sm_list = best_dict[None]
except KeyError:
best_sm_list, = best_dict.values()
best_sm_list, = list(best_dict.values())
if len(best_sm_list) < len(sm_list):
sm_dict[k] = list(set(sm_list).difference(best_sm_list))
sm_list = best_sm_list
......@@ -367,7 +367,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
old_dict[sm] = old_sm
sm = None
deleted = old_dict.items()
deleted = list(old_dict.items())
for delivery, sm_dict in deleted:
if not sm_dict:
del old_dict[delivery]
......@@ -386,7 +386,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
del AppliedRule.isIndexable, SimulationMovement.isIndexable
self.recursiveReindexObject()
assert str not in map(type, old_dict), old_dict
return {k: sum(v.values(), []) for k, v in deleted}, delivery_set
return {k: sum(list(v.values()), []) for k, v in deleted}, delivery_set
simulation_tool._delObject(self.getId())
def _checkExpand(self):
......
......@@ -112,7 +112,7 @@ class ContributionPredicate(Predicate, XMLObject):
tested_base_category[bc] = tested_base_category[bc] or \
context.isMemberOf(c)
result = result and (0 not in tested_base_category.values())
result = result and (0 not in list(tested_base_category.values()))
# Test method calls
test_method_id_list = self.getTestMethodIdList()
if test_method_id_list:
......
......@@ -453,7 +453,7 @@ class DeliveryLine(Movement, XMLMatrix, ImmobilisationMovement):
delivery_dict.get(delivery_path, []) + \
[s_m]
for s_m_list_per_movement in delivery_dict.values():
for s_m_list_per_movement in list(delivery_dict.values()):
total_quantity = sum([quantity_dict.get(s_m, s_m.getQuantity()) \
for s_m in s_m_list_per_movement])
if total_quantity != 0.0:
......
......@@ -476,11 +476,11 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
tmp = {}
for match in rx_search.finditer(text):
group = match.group()
group_item_list = match.groupdict().items()
group_item_list = list(match.groupdict().items())
group_item_list.sort()
key = (group, tuple(group_item_list))
tmp[key] = None
for group, group_item_tuple in tmp.keys():
for group, group_item_tuple in list(tmp.keys()):
result.append((group, dict(group_item_tuple)))
return result
......@@ -581,7 +581,7 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
getRelatedList(self)
lista_latest = {}
for o in lista.keys():
for o in list(lista.keys()):
lista_latest[o.getLatestVersionValue()] = True # get latest versions avoiding duplicates again
# remove this document
......@@ -589,7 +589,7 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
# remove last version of document itself from related documents
lista_latest.pop(self.getLatestVersionValue(), None)
return lista_latest.keys()
return list(lista_latest.keys())
### Version and language getters - might be moved one day to a mixin class in base
security.declareProtected(Permissions.View, 'getLatestVersionValue')
......
......@@ -317,7 +317,7 @@ class ImmobilisableItem(Item, Amount):
Returns a list of dictionaries representing immobilisation periods for the object
from_date is included, to_date is excluded
"""
kw_key_list = kw.keys()
kw_key_list = list(kw.keys())
kw_key_list.sort()
if kw_key_list.count('immo_cache_dict'):
kw_key_list.remove('immo_cache_dict')
......@@ -337,7 +337,7 @@ class ImmobilisableItem(Item, Amount):
previous_period = period_list[-1]
if previous_period['stop_date'] == current_period['start_date']:
if len(keys) == 0:
for key in previous_period.keys():
for key in list(previous_period.keys()):
if key.split('_')[0] == prefix:
current_period[key] = previous_period[key]
else:
......@@ -568,7 +568,7 @@ class ImmobilisableItem(Item, Amount):
extra_cost_price = current_immo_period.get('start_extra_cost_price')
main_price = current_immo_period.get('start_main_price')
current_immo_period['start_price'] = (main_price or 0.) + (extra_cost_price or 0.)
key_list = current_immo_period.keys()
key_list = list(current_immo_period.keys())
for key in key_list:
value = current_immo_period[key]
if key.find('_') != -1:
......@@ -577,7 +577,7 @@ class ImmobilisableItem(Item, Amount):
else:
# A period wich is alone only copies start values to initial ones
# So it may be invalid later
key_list = current_immo_period.keys()
key_list = list(current_immo_period.keys())
for key in key_list:
value = current_immo_period[key]
if key.find('_') != -1:
......
......@@ -277,7 +277,7 @@ class ImmobilisationMovement(Movement, XMLObject):
if (split_char is not None) and (split_qty != 0):
new_parameter_dict = {}
for key in parameter_dict.keys():
for key in list(parameter_dict.keys()):
param_list = parameter_dict[key]
if param_list is None:
new_parameter_dict[key] = []
......
......@@ -291,11 +291,11 @@ class Inventory(Delivery):
# in new inventory
if len(not_used_inventory_dict):
inventory_uid = self.getUid()
for first_level_key in not_used_inventory_dict.keys():
for first_level_key in list(not_used_inventory_dict.keys()):
inventory_value = \
not_used_inventory_dict[tuple(first_level_key)]
# XXX-Aurel : this code does not work with only one level of variation
for second_level_key in inventory_value.keys():
for second_level_key in list(inventory_value.keys()):
diff_quantity = - inventory_value[tuple(second_level_key)]
kwd = {'uid': inventory_uid,
......
......@@ -286,7 +286,7 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
# applicable rule per reference. It indicates a configuration error.
applicable_rule_dict.setdefault(reference, rule)
applicable_rule_list = applicable_rule_dict.values()
applicable_rule_list = list(applicable_rule_dict.values())
for applied_rule in list(self.objectValues()):
rule = applied_rule.getSpecialiseValue()
try:
......
......@@ -21,7 +21,7 @@ class ComputedAttributeGetItemCompatibleMixin(ZSQLBrain):
"""A brain that supports accessing computed attributes using __getitem__
protocol.
"""
def __init__(self):
def __init__(self, *args, **kw):
# __getitem__ returns the computed attribute directly, but if we access
# brain['node_title'] we expect to have the attribute after computation,
# not the ComputedAttribute attribue instance. Defining a __getitem__
......@@ -41,7 +41,10 @@ class ComputedAttributeGetItemCompatibleMixin(ZSQLBrain):
# ComputedAttribute compatibility for __getitem__
# pylint: disable=E0102
def __getitem__(self, name):
item = self.__super__getitem__(name)
try:
item = self.__super__getitem__(name)
except KeyError:
item = self.__getattribute__(name)
if isinstance(item, ComputedAttribute):
return item.__of__(self)
return item
......
......@@ -41,7 +41,7 @@ from OFS.Image import Pdata, Image as OFSImage
from DateTime import DateTime
def makeSortedTuple(kw):
items = kw.items()
items = list(kw.items())
items.sort()
return tuple(items)
......
......@@ -116,7 +116,7 @@ class MailMessageMixin:
way of representing strings in ERP5.
"""
result = {}
for (name, value) in self._getMessage().items():
for (name, value) in list(self._getMessage().items()):
try:
decoded_header = decode_header(value)
except HeaderParseError as error_message:
......@@ -142,7 +142,7 @@ class MailMessageMixin:
result = []
for i, part in enumerate(self._getMessage().walk()):
if not part.is_multipart():
kw = dict(part.items())
kw = dict(list(part.items()))
kw['uid'] = 'part_%s' % i
kw['index'] = i
filename = part.get_filename()
......@@ -182,7 +182,7 @@ class MailMessageMixin:
if index == i:
# This part should be handled in skin script
# but it was a bit easier to access items here
kw = dict(part.items())
kw = dict(list(part.items()))
content_type = part.get_content_type()
if REQUEST is not None:
filename = part.get_filename()
......
......@@ -130,7 +130,7 @@ class MovementCollectionUpdaterMixin:
prevision_to_decision_map.append((None, no_group_list))
# Second, let us create small groups of movements
for tester_key in prevision_movement_dict.keys():
for tester_key in list(prevision_movement_dict.keys()):
for prevision_movement in prevision_movement_dict[tester_key]:
map_list = []
for decision_movement in decision_movement_dict.get(tester_key, ()):
......
......@@ -53,7 +53,7 @@ class SimulableMixin(Base):
"""
tv = getTransactionalVariable()
key = 'SimulableMixin.updateSimulation', self.getUid()
item_list = kw.items()
item_list = list(kw.items())
try:
kw, ignore = tv[key]
kw.update(item_list)
......
......@@ -120,7 +120,7 @@ def addToDate(date, to_add=None, **kw):
if 1 > return_value[key] % 1 > 0:
return_value[lesser_key_dict[key]] += return_value[key] % 1 * number_less_of_in_dict[key]
return_value[key] = int(return_value[key])
for local_key in return_value.keys():
for local_key in list(return_value.keys()):
if local_key not in ('day', 'year'):
treatPositiveValues(return_value, local_key)
......@@ -197,7 +197,7 @@ def getIntervalBetweenDates(from_date=None, to_date=None,
to_inverse = 0
diff_value = {}
for key in keys.keys():
for key in list(keys.keys()):
if key:
diff_value[key] = 0
......@@ -212,7 +212,7 @@ def getIntervalBetweenDates(from_date=None, to_date=None,
diff_value['day'] = round(to_date - from_date)
returned_value = {}
for key, value in diff_value.items():
for key, value in list(diff_value.items()):
if to_inverse:
returned_value[key] = -value
else:
......
......@@ -110,7 +110,7 @@ class MovementGroupNode:
Get property dict for the futur created object
"""
property_dict = getattr(self, '_property_dict', {}).copy()
for key in property_dict.keys():
for key in list(property_dict.keys()):
if key.startswith('_'):
del(property_dict[key])
return property_dict
......@@ -423,10 +423,10 @@ class FakeMovement:
"""
price_dict = self._getPriceDict()
if len(price_dict) == 1:
return price_dict.keys()[0]
return list(price_dict.keys())[0]
total_quantity = sum(price_dict.values())
return (total_quantity and
sum(price * quantity for price, quantity in price_dict.items())
sum(price * quantity for price, quantity in list(price_dict.items()))
/ float(total_quantity))
def getAddQuantity(self):
......@@ -455,7 +455,7 @@ class FakeMovement:
Return total price
"""
price_dict = self._getPriceDict()
return sum(price * quantity for price, quantity in price_dict.items())
return sum(price * quantity for price, quantity in list(price_dict.items()))
def recursiveReindexObject(self, *args, **kw):
"""
......
......@@ -51,7 +51,7 @@ class TextContent:
# this is probably not html code, try rfc822 parsing
message = email.message_from_string(text)
return {k.capitalize(): '\n'.join(message.get_all(k))
for k in message.keys()}
for k in list(message.keys())}
headers = collections.defaultdict(list)
for meta in tree.iterfind(".//meta"):
......
from urllib import unquote
return unquote(value).decode('base64').split(':', 1)[0]
from urllib.parse import unquote
from base64 import standard_b64decode
return standard_b64decode(unquote(value)).split(b':', 1)[0].decode()
for k, v in kw.items():
for k, v in list(kw.items()):
if v:
if k == "str_object_path":
kw["path"] = v
......
......@@ -4,7 +4,7 @@ translation_list = [
newTempBase(context, 'property_domain_dict/'+k, uid=k,
property_name=v.getPropertyName(),
domain_name=v.getDomainName())
for k, v in context.getPropertyTranslationDomainDict().items()]
for k, v in list(context.getPropertyTranslationDomainDict().items())]
translation_list.sort(key=lambda x: x.getId())
return translation_list
......@@ -131,7 +131,7 @@ if len(listbox_id_list):
for listbox_id in listbox_id_list:
listbox_line_list = []
listbox = kw[listbox_id]
listbox_keys = listbox.keys()
listbox_keys = list(listbox.keys())
listbox_keys.sort()
for key in listbox_keys:
listbox_line = listbox[key]
......@@ -166,7 +166,7 @@ if listbox_uid is not None and 'list_selection_name' in kw:
listbox_uid, uids)
# Remove values which doesn't work with make_query.
clean_kw = {}
for k, v in kw.items() :
for k, v in list(kw.items()) :
if v not in (None, [], ()) :
clean_kw[k] = kw[k]
......
......@@ -60,12 +60,12 @@ def editListBox(listbox_field, listbox):
hidden_attribute_list = [x[0] for x in listbox_field.get_value('global_attributes')]
for hidden_attribute in hidden_attribute_list:
global_property_dict[hidden_attribute] = getattr(request, hidden_attribute, None)
for item_url, listbox_item_dict in listbox.items():
for item_url, listbox_item_dict in list(listbox.items()):
listbox_item_dict.update(global_property_dict)
# Form: '' -> ERP5: None
encapsulated_editor_list = []
cleaned_v = {}
for key, value in listbox_item_dict.items():
for key, value in list(listbox_item_dict.items()):
if hasattr(value, 'edit'):
encapsulated_editor_list.append(value)
else:
......@@ -157,7 +157,7 @@ def editMatrixBox(matrixbox_field, matrixbox):
if cell_range != matrixbox_cell_range:
matrix_context.setCellRange(base_id=cell_base_id, *matrixbox_cell_range)
for cell_index_tuple, cell_dict in matrixbox.items():
for cell_index_tuple, cell_dict in list(matrixbox.items()):
# Only update cells which still exist
if matrix_context.hasInRange(*cell_index_tuple, **k_dict):
cell = matrix_context.newCell(*cell_index_tuple, **k_dict)
......@@ -175,7 +175,7 @@ def editMatrixBox(matrixbox_field, matrixbox):
cell_dict[key] = variated_property
# Form: '' -> ERP5: None
cleaned_v = cell_dict.copy()
for key, value in cleaned_v.items():
for key, value in list(cleaned_v.items()):
if value == '':
cleaned_v[key] = None
cell.edit(edit_order=edit_order, **cleaned_v) # and update the cell specific values
......
......@@ -24,7 +24,7 @@ else:
request = container.REQUEST
request_form = request.form
for k in request_form.keys():
for k in list(request_form.keys()):
del request_form[k]
request.form.update(old_request)
......
......@@ -61,12 +61,12 @@ def getIDFromString(string=None):
# Replace odd chars by safe ascii
string = string.lower()
string = string.strip()
for (safe_char, char_list) in translation_map.items():
for (safe_char, char_list) in list(translation_map.items()):
for char in char_list:
string = string.replace(char, safe_char)
# Exclude all non alphanumeric chars
for char in string:
if char.isalnum() or char in translation_map.keys():
if char.isalnum() or char in list(translation_map.keys()):
clean_id += char
# Delete leading and trailing char which are not alpha-numerics
# This prevent having IDs with starting underscores
......@@ -99,7 +99,7 @@ else:
spreadsheet_list = parser.getSpreadsheetsMapping(no_empty_lines=True)
for table_name in spreadsheet_list.keys():
for table_name in list(spreadsheet_list.keys()):
sheet = spreadsheet_list[table_name]
if not sheet:
continue
......@@ -112,7 +112,7 @@ for table_name in spreadsheet_list.keys():
for column in columns_header:
column_id = getIDFromString(column)
# This give us the information that the path definition has started
path_def_started = 'path_0' in property_map.values()
path_def_started = 'path_0' in list(property_map.values())
# The path of the category has started to be expressed
if column_id == 'path':
property_map[column_index] = 'path_' + str(path_index)
......@@ -177,7 +177,7 @@ for table_name in spreadsheet_list.keys():
# Analyse every cell of the line
category_property_list = {}
cell_index = 0
for (property_id, cell_data) in line_data.items():
for (property_id, cell_data) in list(line_data.items()):
# Try to generate a cell id from cell data
cell_id = getIDFromString(cell_data)
......@@ -223,7 +223,7 @@ for table_name in spreadsheet_list.keys():
category_property_list['path'] = path
# Save the current raw path item value as title if no title column defined
if 'title' not in category_property_list.keys():
if 'title' not in list(category_property_list.keys()):
clean_title = cell_data.strip()
# Only set title if it look like a title
# (i.e. its tranformation to ID is not the same as the original value)
......@@ -280,7 +280,7 @@ for table_name in spreadsheet_list.keys():
# Proceed to next cell
cell_index += 1
line_index += 1
if len(category_property_list) > 0 and 'path' in category_property_list.keys():
if len(category_property_list) > 0 and 'path' in list(category_property_list.keys()):
category_list.append(category_property_list)
if error_list:
return {'error_list':error_list}
......
......@@ -43,6 +43,7 @@ for prop_dict in context.getPropertyMap():
new_value = base_error_message
if new_value != old_value or error:
# check if values are unicode convertible (binary are not)
assert six.PY2 # TODO-py3
if isinstance(new_value, (str, unicode)):
try:
unicode(str(new_value), 'utf-8')
......
......@@ -31,4 +31,4 @@ for item in item_list:
# Return the list of subfield configuration.
return sub_field_dict.values()
return list(sub_field_dict.values())
......@@ -42,4 +42,4 @@ for item in item_list:
# Return the list of subfield configuration.
return sub_field_dict.values()
return list(sub_field_dict.values())
......@@ -21,7 +21,7 @@ for char in s.encode('iso8859_1'):
elif char.isspace() or char in ('+', '-'):
clean_id += '_'
else:
for (safe_char, char_list) in translation_map.items():
for (safe_char, char_list) in list(translation_map.items()):
if char in char_list:
clean_id += safe_char
break
......
......@@ -41,7 +41,7 @@ for workflow_item in workflow_item_list:
# XXX removing str method generate a strange bug
o = newTempBase(portal_object, str(i))
i += 1
for key, value in workflow_item.items():
for key, value in list(workflow_item.items()):
if key == 'serial' and not can_view_history:
continue
if key == wf_state_variable:
......
......@@ -114,7 +114,7 @@ def recurseSyntaxNode(node, criterion=DEFAULT_CRITERION_ALIAS):
result[criterion] = [node.getValue()]
else:
for subnode in node.getNodeList():
for criterion, value_list in recurseSyntaxNode(subnode, criterion=criterion).items():
for criterion, value_list in list(recurseSyntaxNode(subnode, criterion=criterion).items()):
result.setdefault(criterion, []).extend(value_list)
return result
......@@ -126,15 +126,15 @@ result = {}
if node is None:
result['searchabletext'] = searchstring
else:
for criterion, value_list in recurseSyntaxNode(node).items():
for criterion, value_list in list(recurseSyntaxNode(node).items()):
criterion, value_list = resolveCriterion(criterion, value_list)
result.setdefault(criterion, []).extend(value_list)
filtered_result = {}
for criterion, value_list in result.items():
for criterion, value_list in list(result.items()):
if len(value_list) > 0:
filtered_result[criterion] = value_list
result = filtered_result
for criterion, value_list in result.items():
for criterion, value_list in list(result.items()):
# XXX: yuck
if criterion == 'searchabletext':
result['searchabletext'] = ' '.join(value_list)
......
......@@ -41,7 +41,7 @@ erp5_role_dict = {
# Add ERP5 permissions
erp5_permission_dict = {}
for role,permission_list in erp5_role_dict.items():
for role,permission_list in list(erp5_role_dict.items()):
for permission in permission_list:
if permission not in erp5_permission_dict:
erp5_permission_dict[permission] = []
......
......@@ -4,7 +4,7 @@ if kw.get('update', False):
# Ensure ERP5JS correctly refresh the page
request.RESPONSE.setStatus(400)
for k in kw.keys():
for k in list(kw.keys()):
v = kw[k]
if k.endswith('listbox'):
listbox = {}
......
from Products.ERP5Type.Message import translateString
choosen = [choice for choice in editor.values() if choice['workflow_action']]
choosen = [choice for choice in list(editor.values()) if choice['workflow_action']]
if len(choosen) == 1:
return True
......
......@@ -13,7 +13,7 @@ from pprint import pformat
ret = '<html><body><table width=100%>\n'
property_dict = context.showDict().items()
property_dict = list(context.showDict().items())
property_dict.sort()
i = 0
for k,v in property_dict:
......
......@@ -35,7 +35,7 @@ if p.portal_templates.compareVersions(bt1.getVersion(), bt2.getVersion()) < 0:
else:
modified_object_list = getModifiedObjectList(bt1, bt2)
keys = modified_object_list.keys()
keys = list(modified_object_list.keys())
keys.sort()
i = 0
......
......@@ -155,12 +155,12 @@ for skin_folder_id in skin_id_list:
# The nice developper probably have a good reason not to do it.
modified_object_dict[field_path] = '0_keep_non_proxy_field'
for field_path, proxy_field_list in field_library_dict.items():
for field_path, proxy_field_list in list(field_library_dict.items()):
if not proxy_field_list:
modified_object_dict[field_path] = '0_unused_proxy_field'
i = 0
for key, value in modified_object_dict.items():
for key, value in list(modified_object_dict.items()):
line = newTempBase(context, 'tmp_install_%s' %(str(i)))
if isinstance(value, tuple):
value, template_id = value
......
......@@ -20,7 +20,7 @@ getModifiedObjectList = CachingMethod(getModifiedObjectList,
cache_id_generator=cache_id_generator)
modified_object_list = getModifiedObjectList(context)
keys = modified_object_list.keys()
keys = list(modified_object_list.keys())
keys.sort()
no_backup_list = ['Action', 'SiteProperty', 'Module', 'Document',
......
"""Return python source code in business template
"""
import json
import six
class Message:
"""A python code linter message, with a link to edit the source code.
......@@ -50,11 +51,14 @@ def checkPythonScript(script_instance, script_path):
# RestrictedPython.Utilities.utility_builtins
extra_builtins = ['printed', 'same_type', 'string', 'sequence', 'random',
'DateTime', 'whrandom', 'reorder', 'sets', 'test', 'math']
code = script_instance.body()
if six.PY2:
code = unicode(code, 'utf8')
for annotation in json.loads(portal.ERP5Site_checkPythonSourceCodeAsJSON(
{'bound_names': extra_builtins +
script_instance.getBindingAssignments().getAssignedNamesInOrder(),
'params': script_instance.params(),
'code': unicode(script_instance.body(), 'utf8')
'code': code
}))['annotations']:
annotation["script_path"] = script_path
line_list.append(
......@@ -74,8 +78,11 @@ def checkComponent(component_instance):
message=consistency_message.getMessage().translate(),
edit_url=component_relative_url,
jio_key=component_relative_url,),)
code = component_instance.getTextContent()
if six.PY2:
code = unicode(code, 'utf8')
for annotation in json.loads(portal.ERP5Site_checkPythonSourceCodeAsJSON(
{'code': unicode(component_instance.getTextContent(), 'utf8')}))['annotations']:
{'code': code}))['annotations']:
annotation['component_path'] = component_relative_url
line_list.append(
Message(
......
......@@ -27,7 +27,7 @@ for base_category_id in preferred_predicate_category_list:
# Add an empty record only if document does not have the category value and the category is enabled on the document.
category_parent_uid_item_dict[base_category_uid] = [[0, base_category_uid, 1]]
uid_item_list_list = category_parent_uid_item_dict.values()
uid_item_list_list = list(category_parent_uid_item_dict.values())
if uid_item_list_list:
return reduce(lambda a,b:a+b, uid_item_list_list)
return ()
......@@ -19,7 +19,7 @@ for error in error_list:
#print error
return_list.append(error)
for portal_type in nb_types.keys():
for portal_type in list(nb_types.keys()):
# Find the number of each portal type in the catalog
count_result = context.portal_catalog.countResults(portal_type=portal_type)
nb_catalog = count_result[0][0]
......
......@@ -24,7 +24,7 @@ else:
if len(filtered_uid_dict.keys()) > 0 :
selection_tool.checkAll(selection_name, uids, REQUEST=None)
selection_tool.setSelectionToIds(selection_name,
filtered_uid_dict.keys(), REQUEST=request)
list(filtered_uid_dict.keys()), REQUEST=request)
url = selection_tool.getSelectionListUrlFor(
selection_name, REQUEST=request)
......
......@@ -43,7 +43,7 @@ for form in (real_form, target_form):
if listbox is not None:
listbox_line_list = []
listbox = getattr(request,'listbox',None) # XXX: hardcoded field name
listbox_keys = listbox.keys()
listbox_keys = list(listbox.keys())
listbox_keys.sort()
for key in listbox_keys:
listbox_line = listbox[key]
......@@ -75,7 +75,7 @@ batch_size = 100 # XXX
priority = 3
path_list_len = len(path_list)
for i in xrange(0, path_list_len, batch_size):
for i in range(0, path_list_len, batch_size):
current_path_list = path_list[i:i+batch_size]
context.activate(activity='SQLQueue', priority=priority, tag=tag).callMethodOnObjectList(
current_path_list, 'Base_workflowStatusModify', batch_mode=True, **do_action_for_param_dict)
......
......@@ -19,7 +19,7 @@ if hasattr(request, listbox_id):
# initialize the listbox
listbox=request[listbox_id]
keys_list = listbox.keys()
keys_list = list(listbox.keys())
if keys_list != []:
keys_list.sort(key=int)
......
......@@ -37,7 +37,7 @@ try:
hidden_attributes = [x[0] for x in listbox_field.get_value('global_attributes')]
for k in hidden_attributes:
gv[k] = getattr(request, k,None)
for property_, v in listbox.items():
for property_, v in list(listbox.items()):
v.update(gv)
context.setCriterion(property_, **v)
# Update basic attributes
......
......@@ -20,7 +20,7 @@ if statistics_criteria == 'total':
result = []
counter = 0
for cache_key,cache_key_memory in cache_plugin_stats_data.items():
for cache_key,cache_key_memory in list(cache_plugin_stats_data.items()):
obj = newTempBase(context,
'temp_translation_%d' %counter,
cache_key = cache_key,
......
......@@ -31,4 +31,4 @@ for item in item_list:
if item_value in value_list:
sub_field_dict[item_key]['value'] = item_value
return sub_field_dict.values()
return list(sub_field_dict.values())
......@@ -37,7 +37,7 @@ for skin_name, skin_path_list in skins_tool.getSkinPaths():
# leave only duplicating ones
duplicating_selection_name_dict = {}
for selection_name, field_list in selection_name_dict.items():
for selection_name, field_list in list(selection_name_dict.items()):
if len(field_list) > 1:
duplicating_selection_name_dict[selection_name] = field_list
......
......@@ -45,7 +45,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()
keys = list(modified_object_list.keys())
keys.sort()
for i, object_id in enumerate(keys):
object_state, object_class = modified_object_list[object_id]
......
......@@ -143,7 +143,7 @@ class PortalPatch(Explicit):
diff_tree_list = []
# Flatten the list of DiffValues
for key, subset in tree_diff.items():
for key, subset in list(tree_diff.items()):
if isinstance(subset, set):
sublist = list(subset)
for item in sublist:
......
......@@ -336,7 +336,7 @@ class DomainTool(BaseTool):
mapped_value = self.getPortalObject().newContent(temp_object=True,
portal_type='Supply Cell', id='multivalued_mapped_value')
mapped_value._setMappedValuePropertyList(
mapped_value_property_dict.keys())
list(mapped_value_property_dict.keys()))
mapped_value.__dict__.update(mapped_value_property_dict)
return mapped_value
......
......@@ -145,7 +145,7 @@ class IntrospectionTool(LogMixin, BaseTool):
# Unlazyfy URLs and other lazy values so that it can be marshalled
result = {}
for key, action_list in erp5_menu_dict.items():
for key, action_list in list(erp5_menu_dict.items()):
result[key] = [ dict(action) for action in action_list ]
return result
......
......@@ -129,11 +129,11 @@ def buildEmailMessage(from_url, to_url, msg=None,
message.attach(MIMEText(msg, _charset='utf-8'))
if extra_headers:
for key, value in extra_headers.items():
for key, value in list(extra_headers.items()):
message.add_header('X-%s' % key, value)
if additional_headers:
for key, value in additional_headers.items():
for key, value in list(additional_headers.items()):
message.add_header(key, value)
if subject:
......
......@@ -232,7 +232,7 @@ class PasswordTool(BaseTool):
"""
current_date = DateTime()
password_request_dict = self._password_request_dict
for key, (_, date) in password_request_dict.items():
for key, (_, date) in list(password_request_dict.items()):
if date < current_date:
del password_request_dict[key]
......
......@@ -112,4 +112,4 @@ class RoundingTool(BaseTool):
Return the possible decimal rounding option item list which is provided
by python standard decimal module.
"""
return ROUNDING_OPTION_DICT.items()
return list(ROUNDING_OPTION_DICT.items())
......@@ -56,7 +56,7 @@ def remove_acquisition_wrapper(obj):
if isinstance(obj, collections.Mapping):
return obj.__class__({
remove_acquisition_wrapper(k): remove_acquisition_wrapper(v)
for k, v in obj.items()})
for k, v in list(obj.items())})
if isinstance(obj, (collections.Sequence, collections.Set)):
return obj.__class__([remove_acquisition_wrapper(o) for o in obj])
return obj
......@@ -70,7 +70,7 @@ def restore_acquisition_wrapper(obj, context):
if isinstance(obj, collections.Mapping):
return obj.__class__({
restore_acquisition_wrapper(k, context): restore_acquisition_wrapper(v, context)
for k, v in obj.items()})
for k, v in list(obj.items())})
if isinstance(obj, (collections.Sequence, collections.Set)):
return obj.__class__([restore_acquisition_wrapper(o, context) for o in obj])
return obj
......@@ -126,7 +126,7 @@ class Session(UserDict):
def edit(self, **kw):
""" Edit session object. """
for key, item in kw.items():
for key, item in list(kw.items()):
self.__setitem__(key, item)
def __setitem__(self, key, item):
......
......@@ -48,7 +48,12 @@ from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery, SimpleQuery
from Shared.DC.ZRDB.Results import Results
from Products.ERP5Type.Utils import mergeZRDBResults
from App.Extensions import getBrain
# pylint:disable=no-name-in-module
try: # BBB Zope 2.12
from App.Extensions import getBrain
except ImportError:
from Shared.DC.ZRDB.DA import getBrain
# pylint:enable=no-name-in-module
from MySQLdb import ProgrammingError
from MySQLdb.constants.ER import NO_SUCH_TABLE
......@@ -516,7 +521,7 @@ class SimulationTool(BaseTool):
)
from_table_dict[alias] = table
sql_kw.update(catalog_sql_kw)
sql_kw['from_table_list'] = from_table_dict.items()
sql_kw['from_table_list'] = list(from_table_dict.items())
return sql_kw
def _generateKeywordDict(self,
......@@ -1609,7 +1614,7 @@ class SimulationTool(BaseTool):
line_key = getInventoryListKey(line)
line_a = inventory_list_dict.get(line_key)
inventory_list_dict[line_key] = addLineValues(line_a, line)
sorted_inventory_list = inventory_list_dict.values()
sorted_inventory_list = list(inventory_list_dict.values())
# Sort results manually when required
sort_on = new_kw.get('sort_on')
if sort_on:
......
......@@ -120,7 +120,7 @@ def utf8Encode(chaine) :
if charsetSite.lower() in ("utf-8", "utf8"):
return chaine
else:
return unicode(chaine, charsetSite, errors).encode("utf-8", errors)
return str(chaine, charsetSite, errors).encode("utf-8", errors)
def utf8Decode(chaine) :
# because browser upload form is in utf-8 we need it
......@@ -129,7 +129,7 @@ def utf8Decode(chaine) :
return chaine
else:
try:
chaine = unicode(chaine, "utf-8", "strict").encode(charsetSite, "strict")
chaine = str(chaine, "utf-8", "strict").encode(charsetSite, "strict")
except:
chaine = chaine.encode(charsetSite, "strict")
return chaine
......
......@@ -93,7 +93,7 @@ def utf8Encode(chaine) :
if charsetSite.lower() in ("utf-8", "utf8"):
return chaine
else:
return unicode(chaine, charsetSite, errors).encode("utf-8", errors)
return str(chaine, charsetSite, errors).encode("utf-8", errors)
def utf8Decode(chaine) :
# because browser upload form is in utf-8 we need it
......@@ -102,7 +102,7 @@ def utf8Decode(chaine) :
return chaine
else:
try:
chaine = unicode(chaine, "utf-8", "strict").encode(charsetSite, "strict")
chaine = str(chaine, "utf-8", "strict").encode(charsetSite, "strict")
except:
chaine = chaine.encode(charsetSite, "strict")
return chaine
......
......@@ -120,7 +120,7 @@ def utf8Encode(chaine) :
if charsetSite.lower() in ("utf-8", "utf8"):
return chaine
else:
return unicode(chaine, charsetSite, errors).encode("utf-8", errors)
return str(chaine, charsetSite, errors).encode("utf-8", errors)
def utf8Decode(chaine) :
# because browser upload form is in utf-8 we need it
......@@ -129,7 +129,7 @@ def utf8Decode(chaine) :
return chaine
else:
try:
chaine = unicode(chaine, "utf-8", "strict").encode(charsetSite, "strict")
chaine = str(chaine, "utf-8", "strict").encode(charsetSite, "strict")
except:
chaine = chaine.encode(charsetSite, "strict")
return chaine
......
......@@ -68,7 +68,7 @@ if web_mode:
# Set properties to the new object
edit_kw = {}
property_id_list = new_object.propertyIds()
for (key, val) in form_data.items():
for (key, val) in list(form_data.items()):
if key in ACCEPTABLE_FORM_ID_LIST and key[len('clone_'):] in property_id_list:
edit_kw[key[len('clone_'):]] = val
new_object.edit(**edit_kw)
......
......@@ -8,7 +8,7 @@ The script must be called on the context of the document.
def filterDuplicateActions(actions):
new_actions = {}
for action_category, action_list in actions.items():
for action_category, action_list in list(actions.items()):
if action_category == 'object_onlyxhtml_view':
action_category = 'object_view'
......
......@@ -53,7 +53,7 @@ def addDialogIfNeeded(url):
if 'format' in parameter_kw:
# if format is passed in action url: remove it
target_format = parameter_kw.pop('format')
action = '%s?%s' % (action_id, '&'.join(['='.join(tuple_parameter) for tuple_parameter in parameter_kw.items()]))
action = '%s?%s' % (action_id, '&'.join(['='.join(tuple_parameter) for tuple_parameter in list(parameter_kw.items())]))
url = '%s/Base_viewOOoPrintDialog?dialog_action_url=%s&base_content_type=%s&field_your_format=%s' % (
context.absolute_url(),
url_quote('%s/%s' % (absolute_url, action)),
......
......@@ -20,7 +20,7 @@ request_form.update(kw)
request_form = context.ERP5Site_filterParameterList(request_form)
request_form.update(keep_items)
parameters = make_query(dict([(k, v) for k, v in request_form.items() if k and v is not None]))
parameters = make_query(dict([(k, v) for k, v in list(request_form.items()) if k and v is not None]))
if len(parameters):
if '?' in redirect_url:
separator = '&'
......
......@@ -20,7 +20,7 @@ keep_items.pop("portal_status_level", None)
if REQUEST is None:
REQUEST = context.REQUEST
for key, value in keep_items.items():
for key, value in list(keep_items.items()):
REQUEST.set(key, value)
return getattr(context, form_id)()
......@@ -10,4 +10,4 @@ kept_names = ('editable_mode', 'ignore_layout', # erp5_web
# Cancel url is always overwritten, except when rendering
# a dialog. So this is safe to propagate it.
return dict((item for item in parameter_list.items() if item[0] in kept_names))
return dict((item for item in list(parameter_list.items()) if item[0] in kept_names))
......@@ -564,7 +564,7 @@ for block_object in planning.content:
bot_list = []
center = ''
# recovering full string that will have to be displayed on the top & bottom line
for info_name in block_object.info.keys():
for info_name in list(block_object.info.keys()):
if 'top' in info_name:
top_string += block_object.info[info_name].info
top_list.append(info_name)
......@@ -604,7 +604,7 @@ for block_object in planning.content:
if block_dict['height'] < car_height:
# there is no room to display any text in the block
# escaping all text
for info_name in block_object.info.keys():
for info_name in list(block_object.info.keys()):
block_object.info[info_name].edit('')
else:
if block_dict['height'] < (car_height* lines):
......
......@@ -75,16 +75,16 @@ else:
# build list from dictionnary structure
# this list will e converted to a string afterwards
returned_list = []
for area_name in properties_structure.keys():
for area_name in list(properties_structure.keys()):
css_dict = properties_structure[area_name]
for class_name in css_dict.keys():
for class_name in list(css_dict.keys()):
if class_name == 'planning_content':
returned_list.append('.%s{' % class_name)
elif class_name == 'planning_box':
returned_list.append('.%s{' % class_name)
else:
returned_list.append('#%s{' % class_name)
for id_ in css_dict[class_name].keys():
for id_ in list(css_dict[class_name].keys()):
if same_type(css_dict[class_name][id_], ''):
returned_list.append('%s:%s;\n' % (id_, css_dict[class_name][id_]))
else:
......
......@@ -234,7 +234,11 @@ class PeriodicityMixin:
"""
returns something like ['Sunday','Monday',...]
"""
return DateTime._days
try:
from DateTime.DateTime import _DAYS
return _DAYS
except ImportError: # BBB DateTime 2.12
return DateTime._days
security.declareProtected(Permissions.AccessContentsInformation, 'getWeekDayItemList')
def getWeekDayItemList(self):
......
......@@ -93,7 +93,7 @@ class PropertyRecordableMixin:
Returns the list of property IDs which have
been recorded.
"""
return self._getRecordedPropertyDict({}).keys()
return list(self._getRecordedPropertyDict({}).keys())
security.declareProtected(Permissions.AccessContentsInformation,
'isPropertyRecorded')
......
......@@ -64,7 +64,7 @@ class ExtractMessageCatalog(TestXHTML):
result[i].update(messages)
f = file('%s.pot' % i, 'w')
for msgid in result[i].keys():
for msgid in list(result[i].keys()):
f.write('msgid "%s"\nmsgstr ""\n\n' % msgid)
......
......@@ -44,6 +44,7 @@ from MySQLdb import ProgrammingError
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex
from zExceptions import BadRequest
class InventoryAPITestCase(ERP5TypeTestCase):
"""Base class for Inventory API Tests {{{
......@@ -130,8 +131,14 @@ class InventoryAPITestCase(ERP5TypeTestCase):
'inventory_module',
self.folder.getId() ]:
folder = self.portal[module]
folder.manage_delObjects(list(folder.objectIds()))
self.portal.portal_skins.custom.manage_delObjects(list(self.portal.portal_skins.custom.objectIds()))
try:
folder.manage_delObjects(list(folder.objectIds()))
except BadRequest:
pass
try:
self.portal.portal_skins.custom.manage_delObjects(list(self.portal.portal_skins.custom.objectIds()))
except BadRequest:
pass
self.tic()
......
......@@ -98,7 +98,7 @@ class TestSecurityMixin(ERP5TypeTestCase):
continue
func_code = method.__code__
error_dict[(func_code.co_filename, func_code.co_firstlineno, method_id)] = True
error_list = error_dict.keys()
error_list = list(error_dict.keys())
if os.environ.get('erp5_debug_mode', None):
pass
else:
......
......@@ -133,7 +133,7 @@ class TestSpellChecking(ERP5TypeTestCase):
# check some suggestion are given for a small mistake
self.assertNotEquals(self.validate_spell('canceled'), {})
self.assertTrue('is misspelled' in \
self.validate_spell('canceled').values()[0])
list(self.validate_spell('canceled').values())[0])
def test_business_template_list_with_workflow_template_item(self):
"""
......
......@@ -121,7 +121,7 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
workflow = workflow_tool._getOb(workflow_id)
class_name = workflow.__class__.__name__
if class_name == 'DCWorkflowDefinition':
for state in workflow.states.items():
for state in list(workflow.states.items()):
state_title = state[1].title
state_id = state[0]
msgid = getMessageIdWithContext(state_title, 'state', workflow_id)
......@@ -134,14 +134,14 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
translation_dict[translated_state_title] = {state_id}
for key, value in translation_dict.items():
for key, value in list(translation_dict.items()):
if len(value) == 1:
translation_dict.pop(key)
if translation_dict != {}:
# State ID has multiple translation associated, and it leads to
# unexpected results for the user when using portal catalog.
rejected_key_list = translation_dict.keys()
rejected_key_list = list(translation_dict.keys())
result_dict = {x: [] for x in rejected_key_list}
error_dict = {x: [] for x in rejected_key_list}
error = 0
......@@ -151,7 +151,7 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
if workflow.__class__.__name__ == 'DCWorkflowDefinition':
workflow_id = workflow.id
workflow_dict = {}
for state_id, state in workflow.states._mapping.items():
for state_id, state in list(workflow.states._mapping.items()):
state_title = state.title
translated_state_title = \
self.portal.Localizer.erp5_ui.gettext(state_title, lang=self.lang)
......@@ -161,13 +161,13 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
# XXX To be improved
not_used_workflow_id_list = []
for key, item_list in result_dict.items():
for key, item_list in list(result_dict.items()):
wrong_state_id_list = [x[1] for x in item_list]
for workflow_id, wrong_state_id, state_title in item_list:
if workflow_id not in not_used_workflow_id_list:
workflow = self.portal.portal_workflow._getOb(workflow_id)
state_id_list = []
for state_id in workflow.states._mapping.keys():
for state_id in list(workflow.states._mapping.keys()):
if (state_id in wrong_state_id_list) and \
(state_id != wrong_state_id):
state_id_list.append(state_id)
......@@ -178,7 +178,7 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
error = 1
if error:
for key, item_list in error_dict.items():
for key, item_list in list(error_dict.items()):
if len(item_list) != 0:
self.logMessage("\n'%s'" % key.encode('utf-8'))
self.logMessage('\t### Conflicting workflow with common states (ie, what user can see) ###')
......
......@@ -187,7 +187,7 @@ class TestXHTMLMixin(ERP5TypeTestCase):
for portal_type in portal_types_module.contentValues(portal_type=\
'Base Type'):
if portal_type.getId().endswith('Module'):
for k, v in portal_type.getPropertyTranslationDomainDict().items():
for k, v in list(portal_type.getPropertyTranslationDomainDict().items()):
if k in ('title', 'short_title') and v.getDomainName() != 'erp5_ui':
error_list.append('"%s" should use erp5_ui for %s' % \
(portal_type.getId(), k))
......@@ -407,7 +407,7 @@ class TestXHTMLMixin(ERP5TypeTestCase):
for id_ in skin_folder.objectIds():
if id_.startswith('Preference_view'):
addPreferenceView(skin_folder.id, id_)
for view_id, location_list in preference_view_id_dict.items():
for view_id, location_list in list(preference_view_id_dict.items()):
if len(location_list) > 1:
error_list.extend(location_list)
self.assertEqual(error_list, [])
......@@ -713,7 +713,7 @@ def addTestMethodDynamically(
business_template_info_list.append(business_template_info)
for business_template_info in business_template_info_list:
for portal_type, action_information_list in business_template_info.actions.items():
for portal_type, action_information_list in list(business_template_info.actions.items()):
for action_information in action_information_list:
if (action_information['category'] in ('object_view', 'object_list') and
action_information['visible']==1 and
......
......@@ -774,7 +774,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
query = ComplexQuery(
[
SimpleQuery(**{key : value})
for key, value in local_role_column_dict.items()
for key, value in list(local_role_column_dict.items())
] + [query],
logical_operator='AND',
)
......@@ -1050,11 +1050,11 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
identity_criterion = getattr(object,'_identity_criterion',None)
range_criterion = getattr(object,'_range_criterion',None)
if identity_criterion is not None:
for property, value in identity_criterion.items():
for property, value in list(identity_criterion.items()):
if value is not None:
property_dict[property] = value
if range_criterion is not None:
for property, (min, max) in range_criterion.items():
for property, (min, max) in list(range_criterion.items()):
if min is not None:
property_dict['%s_range_min' % property] = min
if max is not None:
......@@ -1436,7 +1436,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
break
queries_by_connection_id = defaultdict(list)
for connection_id, method_list in method_list_by_connection_id.items():
for connection_id, method_list in list(method_list_by_connection_id.items()):
connection = connection_by_connection_id[connection_id]
db = connection()
with db.lock():
......@@ -1448,7 +1448,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
for query in queries_by_connection_id[connection_id]:
db.query(query)
return sum(queries_by_connection_id.values(), [])
return sum(list(queries_by_connection_id.values()), [])
security.declarePublic('getDocumentValueList')
def getDocumentValueList(self, sql_catalog_id=None,
......
......@@ -114,7 +114,7 @@ class NumericCaptchaProvider(object):
def generate(self, field):
# First step : generate the calculus. It is really simple.
terms = [str(random.randint(1, 20)), random.choice(self.operator_set.keys())]
terms = [str(random.randint(1, 20)), random.choice(list(self.operator_set.keys()))]
#XXX: Find a way to prevent too complex captchas (for instance 11*7*19...)
#terms += [str(random.randint(1, 20)), random.choice(operator_set.keys())]
terms.append(str(random.randint(1, 20)))
......@@ -128,7 +128,7 @@ class NumericCaptchaProvider(object):
def getHTML(self, field, captcha_key):
# Make the text harder to parse for a computer
calculus_text = captcha_key
for (operator, replacement) in self.operator_set.items():
for (operator, replacement) in list(self.operator_set.items()):
calculus_text = calculus_text.replace(operator, replacement)
return "<span class=\"%s\">%s</span>" % (field.get_value('css_class'), calculus_text)
......
......@@ -26,6 +26,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import six
import hashlib
import re
import six
......@@ -109,7 +110,7 @@ def isCacheable(value):
dic = getattr(value, '__dict__', None)
if dic is not None:
for i in dic.values():
for i in list(dic.values()):
jar = getattr(i, '_p_jar', None)
if jar is not None:
return False
......@@ -133,7 +134,7 @@ def getFieldDict(field, value_type):
else:
raise ValueError('value_type must be values or tales')
template_field = field.getRecursiveTemplateField()
for ui_field_id in template_field.form.fields.keys():
for ui_field_id in list(template_field.form.fields.keys()):
result[ui_field_id] = get_method(ui_field_id)
else:
if value_type=='values':
......@@ -142,7 +143,7 @@ def getFieldDict(field, value_type):
get_method = getattr(field, 'get_tales')
else:
raise ValueError('value_type must be values or tales')
for ui_field_id in field.form.fields.keys():
for ui_field_id in list(field.form.fields.keys()):
result[ui_field_id] = get_method(ui_field_id)
return result
......@@ -447,7 +448,7 @@ def initializeForm(field_registry, form_class=None):
if form_class is None: form_class = ERP5Form
meta_types = []
for meta_type, field in field_registry.get_field_classes().items():
for meta_type, field in list(field_registry.get_field_classes().items()):
# don't set up in form if this is a field for internal use only
if field.internal_field:
continue
......@@ -695,7 +696,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
# overriden to keep the order of a field after rename
groups = deepcopy(self.groups)
ret = ZMIForm.manage_renameObject(self, id, new_id, REQUEST=REQUEST)
for group_id, field_id_list in groups.items():
for group_id, field_id_list in list(groups.items()):
if id in field_id_list:
index = field_id_list.index(id)
field_id_list.pop(index)
......@@ -1045,7 +1046,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
# for skin_folder_id in self.getSimilarSkinFolderIdList():
for skin_folder_id in self.getPortalObject().portal_skins.objectIds():
iterate(getattr(skins_tool, skin_folder_id))
proxy_dict_list = proxy_dict.values()
proxy_dict_list = list(proxy_dict.values())
proxy_dict_list.sort(key=lambda x: x['short_path'])
for item in proxy_dict_list:
item['related_proxy_list'].sort(key=lambda x: x['short_path'])
......@@ -1091,14 +1092,14 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
return a==b
def remove_same_value(new_dict, target_dict):
for key, value in new_dict.items():
for key, value in list(new_dict.items()):
target_value = target_dict.get(key)
if force_delegate or is_equal(value, target_value):
del new_dict[key]
return new_dict
def get_group_and_position(field_id):
for i in self.groups.keys():
for i in list(self.groups.keys()):
if field_id in self.groups[i]:
return i, self.groups[i].index(field_id)
......@@ -1111,7 +1112,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
if field_dict is None:
return
for field_id in field_dict.keys():
for field_id in list(field_dict.keys()):
target = field_dict[field_id]
target_form_id, target_field_id = target.split('.')
......@@ -1138,7 +1139,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
getFieldDict(target_field, 'tales'))
if target_field.meta_type=='ProxyField':
for i in new_values.keys():
for i in list(new_values.keys()):
if not i in target_field.delegated_list:
# obsolete variable check
try:
......@@ -1150,7 +1151,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
if is_equal(target_field.get_recursive_orig_value(i),
new_values[i]):
del new_values[i]
for i in new_tales.keys():
for i in list(new_tales.keys()):
if not i in target_field.delegated_list:
# obsolete variable check
try:
......@@ -1211,14 +1212,14 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
return a==b
def remove_same_value(new_dict, target_dict):
for key, value in new_dict.items():
for key, value in list(new_dict.items()):
target_value = target_dict.get(key)
if is_equal(value, target_value):
del new_dict[key]
return new_dict
def get_group_and_position(field_id):
for i in self.groups.keys():
for i in list(self.groups.keys()):
if field_id in self.groups[i]:
return i, self.groups[i].index(field_id)
......@@ -1231,7 +1232,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
if field_dict is None:
return
for field_id in field_dict.keys():
for field_id in list(field_dict.keys()):
# keep current group and position.
group, position = get_group_and_position(field_id)
......
......@@ -115,7 +115,7 @@ class ImageFieldWidget(Widget.TextWidget):
# only add if it's True as conversion machine assume that if it is missing
# then conversion should happen "on the fly"
options['pre_converted_only'] = pre_converted_only
parameters = '&'.join(['%s=%s' % (k, v) for k, v in options.items() \
parameters = '&'.join(['%s=%s' % (k, v) for k, v in list(options.items()) \
if v])
if parameters:
image = '%s?%s' % (image, parameters)
......
......@@ -38,14 +38,14 @@ class FieldValueCacheInteractor(Interactor):
from Products.Formulator.Field import ZMIField
from Products.ERP5Form.ProxyField import ProxyField
from Products.Formulator.Form import ZMIForm
self.on(ZMIField.manage_edit).doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_edit_xmlrpc).doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_tales).doAfter(self.purgeFieldValueCache)
self.on(ZMIField.manage_tales_xmlrpc).doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_edit).doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_edit_target).doAfter(self.purgeFieldValueCache)
self.on(ProxyField.manage_tales).doAfter(self.purgeFieldValueCache)
self.on(ZMIForm.manage_renameObject).doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_edit').doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_edit_xmlrpc').doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_tales').doAfter(self.purgeFieldValueCache)
self.on(ZMIField, 'manage_tales_xmlrpc').doAfter(self.purgeFieldValueCache)
self.on(ProxyField, 'manage_edit').doAfter(self.purgeFieldValueCache)
self.on(ProxyField, 'manage_edit_target').doAfter(self.purgeFieldValueCache)
self.on(ProxyField, 'manage_tales').doAfter(self.purgeFieldValueCache)
self.on(ZMIForm, 'manage_renameObject').doAfter(self.purgeFieldValueCache)
def purgeFieldValueCache(self, method_call_object):
"""
......
......@@ -55,6 +55,7 @@ from Products.PythonScripts.Utility import allow_class
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from warnings import warn
import cgi
import six
DEFAULT_LISTBOX_DISPLAY_STYLE = 'table'
DEFAULT_LISTBOX_PAGE_NAVIGATION_TEMPLATE = 'ListBox_viewSliderPageNavigationRenderer'
......@@ -104,7 +105,7 @@ class CatalogMethodWrapper(MethodWrapper):
# XXX: I'm not sure if this filtering really belongs to here.
# It is probably needed at a more generic level (Forms ? Selection ?), or
# even a more specific one (limited to HTML ?)...
for key, value in kw.items():
for key, value in list(kw.items()):
if value == '':
kw.pop(key)
return getattr(self.context, self.method_name)(*args, **kw)
......@@ -669,7 +670,7 @@ class ListBoxRenderer:
def getTitle(self):
"""Return the title. Make sure that it is in unicode.
"""
return unicode(self.field.get_value('title'), self.getEncoding())
return self.field.get_value('title')
def getMaxLineNumber(self):
"""Return the maximum number of lines shown in a page.
......@@ -858,7 +859,10 @@ class ListBoxRenderer:
"""Return the columns. Make sure that the titles are in unicode.
"""
columns = self.field.get_value('columns')
return [(str(c[0]), unicode(c[1], self.getEncoding())) for c in columns]
if six.PY3:
return columns
else:
return [(str(c[0]), str(c[1], self.getEncoding())) for c in columns]
@lazyMethod
def getAllColumnList(self):
......@@ -867,9 +871,14 @@ class ListBoxRenderer:
"""
all_column_list = list(self.getColumnList())
all_column_id_set = {c[0] for c in all_column_list}
all_column_list.extend((str(c[0]), unicode(c[1], self.getEncoding()))
for c in self.field.get_value('all_columns')
if c[0] not in all_column_id_set)
if six.PY3:
all_column_list.extend(c
for c in self.field.get_value('all_columns')
if c[0] not in all_column_id_set)
else:
all_column_list.extend((str(c[0]), str(c[1], self.getEncoding()))
for c in self.field.get_value('all_columns')
if c[0] not in all_column_id_set)
return all_column_list
@lazyMethod
......@@ -884,7 +893,10 @@ class ListBoxRenderer:
"""
stat_columns = self.field.get_value('stat_columns')
if stat_columns:
stat_column_list = [(str(c[0]), unicode(c[1], self.getEncoding())) for c in stat_columns]
if six.PY3:
stat_column_list = stat_columns
else:
stat_column_list = [(str(c[0]), str(c[1], self.getEncoding())) for c in stat_columns]
else:
stat_column_list = [(c[0], c[0]) for c in self.getAllColumnList()]
return stat_column_list
......@@ -914,21 +926,30 @@ class ListBoxRenderer:
"""Return the domain root list. Make sure that the titles are in unicode.
"""
domain_root_list = self.field.get_value('domain_root_list')
return [(str(c[0]), unicode(c[1], self.getEncoding())) for c in domain_root_list]
if six.PY3:
return domain_root_list
else:
return [(str(c[0]), str(c[1], self.getEncoding())) for c in domain_root_list]
@lazyMethod
def getReportRootList(self):
"""Return the report root list. Make sure that the titles are in unicode.
"""
report_root_list = self.field.get_value('report_root_list')
return [(str(c[0]), unicode(c[1], self.getEncoding())) for c in report_root_list]
if six.PY3:
return report_root_list
else:
return [(str(c[0]), str(c[1], self.getEncoding())) for c in report_root_list]
@lazyMethod
def getDisplayStyleList(self):
"""Return the list of avaible display style. Make sure that the
titles are in unicode"""
display_style_list = self.field.get_value('display_style_list')
return [(str(c[0]), unicode(c[1], self.getEncoding())) for c in \
if six.PY3:
return display_style_list
else:
return [(str(c[0]), str(c[1], self.getEncoding())) for c in \
display_style_list]
@lazyMethod
......@@ -1165,7 +1186,7 @@ class ListBoxRenderer:
params.setdefault(k, v)
search_prefix = 'search_%s_' % (self.getId(), )
for k, v in params.items():
for k, v in list(params.items()):
if k.startswith(search_prefix):
params[k[len(search_prefix):]] = v
......@@ -1194,12 +1215,12 @@ class ListBoxRenderer:
params.setdefault('meta_type', meta_type_list)
# Remove FileUpload parameters
for k, v in params.items():
for k, v in list(params.items()):
if k == "listbox":
# listbox can also contain useless parameters
new_list = []
for line in v:
for k1, v1 in line.items():
for k1, v1 in list(line.items()):
if hasattr(v1, 'read'):
del line[k1]
new_list.append(line)
......@@ -1603,8 +1624,8 @@ class ListBoxRenderer:
param = param_dict.get(alias, param_dict.get(sql, u''))
if isinstance(param, dict):
param = param.get('query', u'')
if isinstance(param, str):
param = unicode(param, self.getEncoding())
if isinstance(param, six.binary_type):
param = param.decode(self.getEncoding())
# Obtain a search field, if any.
form = self.getForm()
......@@ -1686,8 +1707,12 @@ class ListBoxRenderer:
if editable_field is not None:
processed_value = editable_field.render_view(value=original_value)
if not isinstance(processed_value, unicode):
processed_value = unicode(str(processed_value), self.getEncoding(), 'replace')
if not isinstance(processed_value, str):
if six.PY3:
processed_value = str(processed_value).encode(
self.getEncoding(), 'replace').decode()
else:
processed_value = str(str(processed_value), self.getEncoding(), 'replace')
value_list.append((original_value, processed_value))
......@@ -2280,8 +2305,12 @@ class ListBoxRendererLine:
# Process the value.
if processed_value is None:
processed_value = u''
elif not isinstance(processed_value, unicode):
processed_value = unicode(str(processed_value), renderer.getEncoding(), 'replace')
elif not isinstance(processed_value, str):
if six.PY3:
processed_value = str(processed_value).encode(
renderer.getEncoding(), 'replace').decode()
else:
processed_value = str(str(processed_value), renderer.getEncoding(), 'replace')
value_list.append((original_value, processed_value))
......@@ -2395,8 +2424,8 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
except AttributeError:
pass
if isinstance(url, str):
url = unicode(url, encoding)
if isinstance(url, bytes):
url = str(url, encoding)
if editable_field is not None:
uid = self.getUid()
......@@ -2459,8 +2488,8 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
editable=(not self.isSummary()) \
and listbox_defines_column_as_editable and editable,
)
if isinstance(cell_html, str):
cell_html = unicode(cell_html, encoding)
if isinstance(cell_html, bytes):
cell_html = str(cell_html, encoding)
else:
cell_html = u''
......@@ -2587,7 +2616,7 @@ class ListBoxHTMLRenderer(ListBoxRenderer):
update_selection = False
form_dict = request.form
listbox_kw = selection.getParams()
listbox_arguments_list = [x for x in form_dict.keys() if x.startswith(field_id)]
listbox_arguments_list = [x for x in list(form_dict.keys()) if x.startswith(field_id)]
for original_listbox_argument in listbox_arguments_list:
listbox_argument = original_listbox_argument.replace('%s_' %field_id, '', 1)
listbox_argument_value = form_dict.get(original_listbox_argument, None)
......@@ -2661,7 +2690,7 @@ class ListBoxListRenderer(ListBoxRenderer):
listboxline.checkLine(uid in checked_uid_set)
for (original_value, processed_value), (sql, title) in zip(line.getValueList(), self.getSelectedColumnList()):
if isinstance(original_value, unicode):
if isinstance(original_value, str):
value = original_value.encode(self.getEncoding())
else:
value = original_value
......@@ -2679,7 +2708,7 @@ class ListBoxListRenderer(ListBoxRenderer):
stat_listboxline.markStatLine()
for (original_value, processed_value), (sql, title) in zip(self.getStatValueList(), self.getSelectedColumnList()):
if isinstance(original_value, unicode):
if isinstance(original_value, str):
value = original_value.encode(self.getEncoding())
else:
value = original_value
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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