Commit 0048d09c authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

py2/py3: stop using deprecated has_key().

parent 21ece045
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
website = context.getWebSiteValue() website = context.getWebSiteValue()
REQUEST = context.REQUEST REQUEST = context.REQUEST
if REQUEST.has_key('portal_skin'): if 'portal_skin' in REQUEST:
context.portal_skins.clearSkinCookie() context.portal_skins.clearSkinCookie()
#XXX get cookie name from key authentication plugin #XXX get cookie name from key authentication plugin
......
...@@ -20,7 +20,7 @@ def getSubFieldDict(): ...@@ -20,7 +20,7 @@ def getSubFieldDict():
item_key = '/'.join(item_split[:split_depth]) item_key = '/'.join(item_split[:split_depth])
# Create a new subfield if necessary # Create a new subfield if necessary
if not sub_field_dict.has_key(item_key): if item_key not in sub_field_dict:
# Create property dict (key are field parameters) # Create property dict (key are field parameters)
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key sub_field_property_dict['key'] = item_key
...@@ -57,7 +57,7 @@ for item_value in value_list: ...@@ -57,7 +57,7 @@ for item_value in value_list:
item_split = item_value.split('/') item_split = item_value.split('/')
item_key = '/'.join(item_split[:split_depth]) item_key = '/'.join(item_split[:split_depth])
if not sub_field_dict.has_key(item_key): if item_key not in sub_field_dict:
# This can only happens if an accounting plan have been uninstalled # This can only happens if an accounting plan have been uninstalled
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key sub_field_property_dict['key'] = item_key
......
...@@ -142,7 +142,7 @@ else: ...@@ -142,7 +142,7 @@ else:
reference_dict = getattr(context, property_override_method_id)(instance=actual_object) reference_dict = getattr(context, property_override_method_id)(instance=actual_object)
do_reindex = False do_reindex = False
for attribute_id in attribute_id_list: for attribute_id in attribute_id_list:
if not reference_dict.has_key(attribute_id): if attribute_id not in reference_dict:
reference_value = actual_object.getProperty(attribute_id) reference_value = actual_object.getProperty(attribute_id)
else: else:
reference_value = reference_dict[attribute_id] reference_value = reference_dict[attribute_id]
......
...@@ -29,7 +29,7 @@ if form_id is not None: ...@@ -29,7 +29,7 @@ if form_id is not None:
# Make sure editors are pushed back as values into the REQUEST object # Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields(): for f in form.get_fields():
field_id = f.id field_id = f.id
if request.has_key(field_id): if field_id in request:
value = request.get(field_id) value = request.get(field_id)
if callable(value): if callable(value):
value(request) value(request)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
""" """
website = context.getWebSiteValue() website = context.getWebSiteValue()
REQUEST = context.REQUEST REQUEST = context.REQUEST
if REQUEST.has_key('portal_skin'): if 'portal_skin' in REQUEST:
context.portal_skins.clearSkinCookie() context.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/') REQUEST.RESPONSE.expireCookie('__ac', path='/')
REQUEST.RESPONSE.expireCookie('__ac_facebook_hash', path='/') REQUEST.RESPONSE.expireCookie('__ac_facebook_hash', path='/')
......
...@@ -10,7 +10,7 @@ for item in item_list: ...@@ -10,7 +10,7 @@ for item in item_list:
item_key = '/'.join(item_split[:split_depth]) item_key = '/'.join(item_split[:split_depth])
base_category = item_split[0] base_category = item_split[0]
# Create a new subfield if necessary # Create a new subfield if necessary
if not sub_field_dict.has_key(item_key): if item_key not in sub_field_dict:
# Create property dict (key are field parameters) # Create property dict (key are field parameters)
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key sub_field_property_dict['key'] = item_key
......
...@@ -86,7 +86,7 @@ try: ...@@ -86,7 +86,7 @@ try:
bath = '' bath = ''
for item in created_item_list: for item in created_item_list:
bath = str(item.grouping_reference) bath = str(item.grouping_reference)
if bath_dict.has_key(bath): if bath in bath_dict:
bath_dict[str(bath)].extend([item]) bath_dict[str(bath)].extend([item])
else: else:
bath_dict[str(bath)] = [item] bath_dict[str(bath)] = [item]
...@@ -142,7 +142,7 @@ try: ...@@ -142,7 +142,7 @@ try:
new_movement = context.portal_simulation.solveMovement(movement, None, 'SplitQuantity', additional_parameters={'aggregate_list':apparel_bath_list}, start_date=start_date, stop_date=stop_date, quantity=quantity) new_movement = context.portal_simulation.solveMovement(movement, None, 'SplitQuantity', additional_parameters={'aggregate_list':apparel_bath_list}, start_date=start_date, stop_date=stop_date, quantity=quantity)
movement_list.append(new_movement[0].getRelativeUrl()) movement_list.append(new_movement[0].getRelativeUrl())
# update root movement if require # update root movement if require
if bath_dict.has_key(movement_bath): if movement_bath in bath_dict:
items = bath_dict[movement_bath] items = bath_dict[movement_bath]
quantity = 0 quantity = 0
for item in items: for item in items:
...@@ -181,7 +181,7 @@ try: ...@@ -181,7 +181,7 @@ try:
if cell.getVariationText() == variation_text: if cell.getVariationText() == variation_text:
# update aggregate list with items # update aggregate list with items
cell_aggregate_list = cell.getAggregateValueList() cell_aggregate_list = cell.getAggregateValueList()
if bath_dict.has_key(line_bath): if line_bath in bath_dict:
# new items on cell # new items on cell
cell_item = bath_dict[line_bath] cell_item = bath_dict[line_bath]
cell_aggregate_list.extend(cell_item) cell_aggregate_list.extend(cell_item)
......
...@@ -159,10 +159,10 @@ class TestApparelModel(ERP5TypeTestCase): ...@@ -159,10 +159,10 @@ class TestApparelModel(ERP5TypeTestCase):
self.assertEqual(elasthane.getProperty('quantity'), 0.12) self.assertEqual(elasthane.getProperty('quantity'), 0.12)
# check indexes are present # check indexes are present
self.assertTrue(apparel_model.index.has_key('composition')) self.assertTrue('composition' in apparel_model.index)
index = apparel_model.index['composition'][0] index = apparel_model.index['composition'][0]
self.assertTrue(index.has_key('composition/elasthane')) self.assertTrue('composition/elasthane' in index)
self.assertTrue(index.has_key('composition/acrylique')) self.assertTrue('composition/acrylique' in index)
def test_checkCopyColourRangeVariation(self): def test_checkCopyColourRangeVariation(self):
''' '''
......
...@@ -26,7 +26,7 @@ node_inventory_dict = {} ...@@ -26,7 +26,7 @@ node_inventory_dict = {}
activate_kw = {"tag": tag} activate_kw = {"tag": tag}
for inventory in node_inventory_list: for inventory in node_inventory_list:
# Do only one inventory per node # Do only one inventory per node
if not node_inventory_dict.has_key(inventory.node_relative_url): if inventory.node_relative_url not in node_inventory_dict:
inv = inventory_module.newContent(portal_type="Archive Inventory", inv = inventory_module.newContent(portal_type="Archive Inventory",
destination=inventory.node_relative_url, destination=inventory.node_relative_url,
...@@ -99,7 +99,7 @@ for inv in node_inventory_dict.values(): ...@@ -99,7 +99,7 @@ for inv in node_inventory_dict.values():
payment_inventory_dict = {} payment_inventory_dict = {}
for inventory in payment_inventory_list: for inventory in payment_inventory_list:
# Do only one inventory per payment # Do only one inventory per payment
if not payment_inventory_dict.has_key(inventory.payment_uid): if inventory.payment_uid not in payment_inventory_dict:
inv = inventory_module.newContent(portal_type="Archive Inventory", inv = inventory_module.newContent(portal_type="Archive Inventory",
destination=inventory.node_relative_url, destination=inventory.node_relative_url,
......
...@@ -96,7 +96,7 @@ class MovementGroup(XMLObject): ...@@ -96,7 +96,7 @@ class MovementGroup(XMLObject):
# XXX it can be wrong. we need a good way to get hash value, or # XXX it can be wrong. we need a good way to get hash value, or
# we should compare for all pairs. # we should compare for all pairs.
key = repr(property_dict) key = repr(property_dict)
if tmp_dict.has_key(key): if key in tmp_dict:
tmp_dict[key][0].append(movement) tmp_dict[key][0].append(movement)
else: else:
tmp_dict[key] = [[movement], property_dict] tmp_dict[key] = [[movement], property_dict]
......
...@@ -254,7 +254,7 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -254,7 +254,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
delta = inventory_item.inventory - min_stock delta = inventory_item.inventory - min_stock
node_uid = inventory_item.node_uid node_uid = inventory_item.node_uid
# if node_uid is provided, we have to look at all provided nodes # if node_uid is provided, we have to look at all provided nodes
if kw.has_key('node_uid'): if 'node_uid' in kw:
node_uid = kw['node_uid'] node_uid = kw['node_uid']
optimized_kw = {} optimized_kw = {}
if kw.get('group_by_variation', 1): if kw.get('group_by_variation', 1):
......
...@@ -58,7 +58,7 @@ result_list = context.portal_catalog.countResults(select_dict={'date': 'DATE_FOR ...@@ -58,7 +58,7 @@ result_list = context.portal_catalog.countResults(select_dict={'date': 'DATE_FOR
# build result dict per portal_type then period # build result dict per portal_type then period
portal_type_count_dict = {} portal_type_count_dict = {}
for result in result_list: for result in result_list:
if portal_type_count_dict.has_key(result[2]): if result[2] in portal_type_count_dict:
portal_type_count_dict[result[2]][result[1]] = result[0] portal_type_count_dict[result[2]][result[1]] = result[0]
else: else:
portal_type_count_dict[result[2]] = {result[1]:result[0]} portal_type_count_dict[result[2]] = {result[1]:result[0]}
...@@ -68,7 +68,7 @@ line_list = [] ...@@ -68,7 +68,7 @@ line_list = []
append = line_list.append append = line_list.append
period_count_dict = {} period_count_dict = {}
for portal_type in portal_type_list: for portal_type in portal_type_list:
if portal_type_count_dict.has_key(portal_type): if portal_type in portal_type_count_dict:
period_count = portal_type_count_dict[portal_type] period_count = portal_type_count_dict[portal_type]
obj = Object(uid="new_") obj = Object(uid="new_")
obj["document_type"] = context.Base_translateString(portal_type) obj["document_type"] = context.Base_translateString(portal_type)
...@@ -76,10 +76,10 @@ for portal_type in portal_type_list: ...@@ -76,10 +76,10 @@ for portal_type in portal_type_list:
continue continue
line_counter = 0 line_counter = 0
for period in period_list: for period in period_list:
if period_count.has_key(period): if period in period_count:
obj[period] = period_count[period] obj[period] = period_count[period]
line_counter += period_count[period] line_counter += period_count[period]
if period_count_dict.has_key(period): if period in period_count_dict:
period_count_dict[period] = period_count_dict[period] + period_count[period] period_count_dict[period] = period_count_dict[period] + period_count[period]
else: else:
period_count_dict[period] = period_count[period] period_count_dict[period] = period_count[period]
...@@ -99,7 +99,7 @@ obj = Object(uid="new_") ...@@ -99,7 +99,7 @@ obj = Object(uid="new_")
obj["document_type"] = 'Total' obj["document_type"] = 'Total'
line_counter = 0 line_counter = 0
for period in period_list: for period in period_list:
if period_count_dict.has_key(period): if period in period_count_dict:
obj[period] = period_count_dict[period] obj[period] = period_count_dict[period]
line_counter += period_count_dict[period] line_counter += period_count_dict[period]
else: else:
......
...@@ -43,7 +43,7 @@ for item in item_list: ...@@ -43,7 +43,7 @@ for item in item_list:
if item_key in line_level_variation_list: if item_key in line_level_variation_list:
multi = False multi = False
if not sub_field_dict.has_key(item_key): if item_key not in sub_field_dict:
# Create property dict # Create property dict
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key sub_field_property_dict['key'] = item_key
......
...@@ -35,7 +35,7 @@ for item in item_list: ...@@ -35,7 +35,7 @@ for item in item_list:
base_category = item_split[0] base_category = item_split[0]
multi = False # XXX or now budget level are only single value. multi = False # XXX or now budget level are only single value.
if not sub_field_dict.has_key(item_key): if item_key not in sub_field_dict:
# Create property dict # Create property dict
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key sub_field_property_dict['key'] = item_key
......
...@@ -21,7 +21,7 @@ if form_id is not None: ...@@ -21,7 +21,7 @@ if form_id is not None:
# Make sure editors are pushed back as values into the REQUEST object # Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields(): for f in form.get_fields():
field_id = f.id field_id = f.id
if request.has_key(field_id): if field_id in request:
value = request.get(field_id) value = request.get(field_id)
if callable(value): if callable(value):
value(request) value(request)
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
current_web_section = context.REQUEST.get('current_web_section', context) current_web_section = context.REQUEST.get('current_web_section', context)
product_list = [] product_list = []
if not kw.has_key('portal_type'): if 'portal_type' not in kw:
kw['portal_type'] = 'Product' kw['portal_type'] = 'Product'
if not kw.has_key('limit'): if 'limit' not in kw:
kw['limit'] = limit kw['limit'] = limit
if not kw.has_key('all_versions'): if 'all_versions' not in kw:
kw['all_versions'] = 1 kw['all_versions'] = 1
if not kw.has_key('all_languages'): if 'all_languages' not in kw:
kw['all_languages'] = 1 kw['all_languages'] = 1
for key in ['limit','all_versions','all_languages']: for key in ['limit','all_versions','all_languages']:
......
...@@ -5,7 +5,7 @@ from random import choice ...@@ -5,7 +5,7 @@ from random import choice
web_site = context.getWebSiteValue() or context.REQUEST.get('current_web_site') web_site = context.getWebSiteValue() or context.REQUEST.get('current_web_site')
if not kw.has_key('portal_type'): if 'portal_type' not in kw:
kw['portal_type'] = 'Product' kw['portal_type'] = 'Product'
# Getting all the products from all the visible Web Section. # Getting all the products from all the visible Web Section.
......
...@@ -74,7 +74,7 @@ def getWorkflowHistory(state, document, remove_undo=0, remove_not_displayed=0): ...@@ -74,7 +74,7 @@ def getWorkflowHistory(state, document, remove_undo=0, remove_not_displayed=0):
else: else:
result = [] result = []
for x in wh: for x in wh:
if x.has_key('undo') and x['undo'] == 1: if 'undo' in x and x['undo'] == 1:
result.pop() result.pop()
else: else:
result.append(x.copy()) result.append(x.copy())
...@@ -95,7 +95,7 @@ def _updateWorkflowHistory(workflow, document, status_dict): ...@@ -95,7 +95,7 @@ def _updateWorkflowHistory(workflow, document, status_dict):
# Add an entry for the workflow in the history # Add an entry for the workflow in the history
workflow_key = workflow.getReference() workflow_key = workflow.getReference()
if not document.workflow_history.has_key(workflow_key): if workflow_key not in document.workflow_history:
document.workflow_history[workflow_key] = () document.workflow_history[workflow_key] = ()
# Update history # Update history
......
...@@ -7,7 +7,7 @@ items = [] ...@@ -7,7 +7,7 @@ items = []
# get the user information # get the user information
for line in listbox: for line in listbox:
if line.has_key('listbox_key') and line['item_title'] not in ('', None): if 'listbox_key' in line and line['item_title'] not in ('', None):
line_id = int(line['listbox_key']) line_id = int(line['listbox_key'])
item = {} item = {}
item['id'] = line_id item['id'] = line_id
......
...@@ -7,7 +7,7 @@ items = [] ...@@ -7,7 +7,7 @@ items = []
# get the user information # get the user information
for line in listbox: for line in listbox:
if line.has_key('listbox_key') and line['item_title'] not in ('', None): if 'listbox_key' in line and line['item_title'] not in ('', None):
line_id = int(line['listbox_key']) line_id = int(line['listbox_key'])
item = {} item = {}
item['id'] = line_id item['id'] = line_id
......
...@@ -7,7 +7,7 @@ items = [] ...@@ -7,7 +7,7 @@ items = []
# get the user information # get the user information
for line in listbox: for line in listbox:
if line.has_key('listbox_key') and line['item_title'] not in ('', None): if 'listbox_key' in line and line['item_title'] not in ('', None):
line_id = int(line['listbox_key']) line_id = int(line['listbox_key'])
item = {} item = {}
item['id'] = line_id item['id'] = line_id
......
...@@ -50,7 +50,7 @@ fast_input_lines = [] ...@@ -50,7 +50,7 @@ fast_input_lines = []
# get the fast input form datas # get the fast input form datas
for inputline in listbox: for inputline in listbox:
if inputline.has_key('listbox_key'): if 'listbox_key' in inputline:
line = {} line = {}
line['id'] = int(inputline['listbox_key']) line['id'] = int(inputline['listbox_key'])
for data_name in input_data_names: for data_name in input_data_names:
......
...@@ -34,7 +34,7 @@ fast_input_lines = [] ...@@ -34,7 +34,7 @@ fast_input_lines = []
# get the fast input form datas # get the fast input form datas
for inputline in listbox: for inputline in listbox:
if inputline.has_key('listbox_key'): if 'listbox_key' in inputline:
line = {} line = {}
line['id'] = int(inputline['listbox_key']) line['id'] = int(inputline['listbox_key'])
for data_name in input_data_names: for data_name in input_data_names:
...@@ -75,7 +75,7 @@ for line in fast_input_lines: ...@@ -75,7 +75,7 @@ for line in fast_input_lines:
new_1st_level_sub_items.append(new_2nd_level_item) new_1st_level_sub_items.append(new_2nd_level_item)
if has_1st_level == True: if has_1st_level == True:
if structured_input_data.has_key(new_1st_level_key): if new_1st_level_key in structured_input_data:
new_1st_level_sub_items = structured_input_data[new_1st_level_key][1] + new_1st_level_sub_items new_1st_level_sub_items = structured_input_data[new_1st_level_key][1] + new_1st_level_sub_items
else: else:
structured_input_data[new_1st_level_key] = [None, None] structured_input_data[new_1st_level_key] = [None, None]
......
...@@ -14,7 +14,7 @@ except: ...@@ -14,7 +14,7 @@ except:
# get the user information # get the user information
for line in listbox: for line in listbox:
if line.has_key('listbox_key') and line['title'] not in ('', None): if 'listbox_key' in line and line['title'] not in ('', None):
line_id = int(line['listbox_key']) line_id = int(line['listbox_key'])
item = {} item = {}
item['id'] = line_id item['id'] = line_id
......
...@@ -14,7 +14,7 @@ except: #XXX ...@@ -14,7 +14,7 @@ except: #XXX
# get the user information # get the user information
for line in listbox: for line in listbox:
if line.has_key('listbox_key') and line['title'] not in ('', None): if 'listbox_key' in line and line['title'] not in ('', None):
line_id = int(line['listbox_key']) line_id = int(line['listbox_key'])
item = {} item = {}
item['id'] = line_id item['id'] = line_id
......
...@@ -14,7 +14,7 @@ except: ...@@ -14,7 +14,7 @@ except:
# get the user information # get the user information
for line in listbox: for line in listbox:
if line.has_key('listbox_key') and line['title'] not in ('', None): if 'listbox_key' in line and line['title'] not in ('', None):
line_id = int(line['listbox_key']) line_id = int(line['listbox_key'])
item = {} item = {}
item['id'] = line_id item['id'] = line_id
......
...@@ -10,7 +10,7 @@ items = [] ...@@ -10,7 +10,7 @@ items = []
# get the user information # get the user information
for inputline in listbox: for inputline in listbox:
if inputline.has_key('listbox_key'): if 'listbox_key' in inputline:
scenario = {} scenario = {}
scenario['id'] = int(inputline['listbox_key']) scenario['id'] = int(inputline['listbox_key'])
scenario['title'] = inputline['scenario_title'] scenario['title'] = inputline['scenario_title']
...@@ -55,7 +55,7 @@ for item in items: ...@@ -55,7 +55,7 @@ for item in items:
new_1st_level_item.append(new_2nd_level_item) new_1st_level_item.append(new_2nd_level_item)
if has_1st_level == True: if has_1st_level == True:
if clean_input_lines.has_key(new_1st_level_key): if new_1st_level_key in clean_input_lines:
new_1st_level_item = clean_input_lines[new_1st_level_key] + new_1st_level_item new_1st_level_item = clean_input_lines[new_1st_level_key] + new_1st_level_item
clean_input_lines[new_1st_level_key] = new_1st_level_item clean_input_lines[new_1st_level_key] = new_1st_level_item
......
...@@ -36,7 +36,7 @@ except FormValidationError, validation_errors: ...@@ -36,7 +36,7 @@ except FormValidationError, validation_errors:
# Make sure editors are pushed back as values into the REQUEST object # Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields(): for f in form.get_fields():
field_id = f.id field_id = f.id
if request.has_key(field_id): if field_id in request:
value = request.get(field_id) value = request.get(field_id)
if callable(value): if callable(value):
value(request) value(request)
......
...@@ -79,11 +79,11 @@ class ERP5CookieCrumblerTests (CookieCrumblerTests): ...@@ -79,11 +79,11 @@ class ERP5CookieCrumblerTests (CookieCrumblerTests):
self.req.cookies['__ac_password'] = long_pass self.req.cookies['__ac_password'] = long_pass
self.req.traverse('/') self.req.traverse('/')
self.assert_(self.req.has_key('AUTHENTICATED_USER')) self.assert_('AUTHENTICATED_USER' in self.req)
self.assertEqual(self.req['AUTHENTICATED_USER'].getId(), self.assertEqual(self.req['AUTHENTICATED_USER'].getId(),
'abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm') 'abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm')
resp = self.req.response resp = self.req.response
self.assert_(resp.cookies.has_key('__ac')) self.assert_('__ac' in resp.cookies)
self.credentials = base64.encodestring('%s:%s' % (long_name, long_pass)).replace('\012', '') self.credentials = base64.encodestring('%s:%s' % (long_name, long_pass)).replace('\012', '')
self.assertEqual(resp.cookies['__ac']['value'], self.assertEqual(resp.cookies['__ac']['value'],
self.credentials) self.credentials)
......
...@@ -70,16 +70,16 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -70,16 +70,16 @@ class TestERP5Category(ERP5TypeTestCase):
bc = self.base_cat bc = self.base_cat
if bc not in portal_categories.objectIds(): if bc not in portal_categories.objectIds():
portal_categories.newContent(portal_type='Base Category', id=bc) portal_categories.newContent(portal_type='Base Category', id=bc)
if not portal_categories[bc].has_key('1'): if '1' not in portal_categories[bc]:
portal_categories[bc].newContent(id='1', portal_type='Category') portal_categories[bc].newContent(id='1', portal_type='Category')
self.cat1 = portal_categories[bc]['1'] self.cat1 = portal_categories[bc]['1']
if not self.cat1.has_key('1'): if '1' not in self.cat1:
self.cat1.newContent(id='1', portal_type='Category') self.cat1.newContent(id='1', portal_type='Category')
self.deep_cat1 = self.cat1['1'] self.deep_cat1 = self.cat1['1']
if not portal_categories[bc].has_key('2'): if '2' not in portal_categories[bc]:
portal_categories[bc].newContent(id='2', portal_type='Category') portal_categories[bc].newContent(id='2', portal_type='Category')
self.cat2 = portal_categories[bc]['2'] self.cat2 = portal_categories[bc]['2']
if not self.cat2.has_key('1'): if '1' not in self.cat2:
self.cat2.newContent(id='1', portal_type='Category') self.cat2.newContent(id='1', portal_type='Category')
self.deep_cat2 = self.cat2['1'] self.deep_cat2 = self.cat2['1']
...@@ -90,35 +90,35 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -90,35 +90,35 @@ class TestERP5Category(ERP5TypeTestCase):
self.commit() self.commit()
organisation_module = self.getOrganisationModule() organisation_module = self.getOrganisationModule()
if not organisation_module.has_key('1'): if '1' not in organisation_module:
organisation_module.newContent(id='1', portal_type='Organisation') organisation_module.newContent(id='1', portal_type='Organisation')
self.organisation = organisation_module['1'] self.organisation = organisation_module['1']
if not self.organisation.has_key('1'): if '1' not in self.organisation:
self.organisation.newContent(id='1', portal_type='Telephone') self.organisation.newContent(id='1', portal_type='Telephone')
self.telephone = self.organisation['1'] self.telephone = self.organisation['1']
if not organisation_module.has_key('2'): if '2' not in organisation_module:
organisation_module.newContent(id='2', portal_type='Organisation') organisation_module.newContent(id='2', portal_type='Organisation')
self.organisation2 = organisation_module['2'] self.organisation2 = organisation_module['2']
if not self.organisation2.has_key('1'): if '1' not in self.organisation2:
self.organisation2.newContent(id='1', portal_type='Telephone') self.organisation2.newContent(id='1', portal_type='Telephone')
self.telephone2 = self.organisation2['1'] self.telephone2 = self.organisation2['1']
if not person_module.has_key('1'): if '1' not in person_module:
person_module.newContent(id='1', portal_type = 'Person') person_module.newContent(id='1', portal_type = 'Person')
self.person = person_module['1'] self.person = person_module['1']
bc2 = self.base_cat2 bc2 = self.base_cat2
if bc2 not in portal_categories.objectIds(): if bc2 not in portal_categories.objectIds():
portal_categories.newContent(portal_type='Base Category', id=bc2) portal_categories.newContent(portal_type='Base Category', id=bc2)
if not portal_categories[bc2].has_key('1'): if '1' not in portal_categories[bc2]:
portal_categories[bc2].newContent(id='1', portal_type='Category') portal_categories[bc2].newContent(id='1', portal_type='Category')
self.efg_l1 = portal_categories[bc2]['1'] self.efg_l1 = portal_categories[bc2]['1']
if not self.efg_l1.has_key('11'): if '11' not in self.efg_l1:
self.efg_l1.newContent(id='11', portal_type='Category') self.efg_l1.newContent(id='11', portal_type='Category')
self.efg_l2 = self.efg_l1['11'] self.efg_l2 = self.efg_l1['11']
if not self.efg_l2.has_key('111'): if '111' not in self.efg_l2:
self.efg_l2.newContent(id='111', portal_type='Category') self.efg_l2.newContent(id='111', portal_type='Category')
self.efg_l3 = self.efg_l2['111'] self.efg_l3 = self.efg_l2['111']
if not self.efg_l3.has_key('1111'): if '1111' not in self.efg_l3:
self.efg_l3.newContent(id='1111',portal_type='Category') self.efg_l3.newContent(id='1111',portal_type='Category')
self.efg_l4 = self.efg_l3['1111'] self.efg_l4 = self.efg_l3['1111']
...@@ -128,7 +128,7 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -128,7 +128,7 @@ class TestERP5Category(ERP5TypeTestCase):
content_type_set = set(module_type.getTypeAllowedContentTypeList()) content_type_set = set(module_type.getTypeAllowedContentTypeList())
content_type_set.add('Mapped Value') content_type_set.add('Mapped Value')
module_type._setTypeAllowedContentTypeList(tuple(content_type_set)) module_type._setTypeAllowedContentTypeList(tuple(content_type_set))
if not organisation_module.has_key('predicate'): if 'predicate' not in organisation_module:
organisation_module.newContent(id='predicate', portal_type='Mapped Value') organisation_module.newContent(id='predicate', portal_type='Mapped Value')
predicate = organisation_module['predicate'] predicate = organisation_module['predicate']
predicate.setCriterion('quantity', identity=None, min=None, max=None) predicate.setCriterion('quantity', identity=None, min=None, max=None)
...@@ -139,7 +139,7 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -139,7 +139,7 @@ class TestERP5Category(ERP5TypeTestCase):
def beforeTearDown(self): def beforeTearDown(self):
portal_categories = self.getCategoryTool() portal_categories = self.getCategoryTool()
if portal_categories[self.base_cat].has_key('3'): if '3' in portal_categories[self.base_cat]:
portal_categories[self.base_cat].manage_delObjects('3') portal_categories[self.base_cat].manage_delObjects('3')
self.commitAndTic() self.commitAndTic()
...@@ -149,7 +149,7 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -149,7 +149,7 @@ class TestERP5Category(ERP5TypeTestCase):
self.commitAndTic() self.commitAndTic()
organisation_module = self.getOrganisationModule() organisation_module = self.getOrganisationModule()
if organisation_module.has_key('new_id'): if 'new_id' in organisation_module:
organisation_module.manage_delObjects('new_id') organisation_module.manage_delObjects('new_id')
self.commitAndTic() self.commitAndTic()
......
...@@ -1758,7 +1758,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1758,7 +1758,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
person_module = self.getPersonModule() person_module = self.getPersonModule()
person = person_module.newContent(portal_type='Person') person = person_module.newContent(portal_type='Person')
self.assertFalse(person.hasTitle()) self.assertFalse(person.hasTitle())
self.assertFalse(person.__dict__.has_key('title')) self.assertFalse('title' in person.__dict__)
def test_24_relatedValueAccessor(self): def test_24_relatedValueAccessor(self):
""" """
......
...@@ -6,7 +6,7 @@ for attachment in context.getAttachmentInformationList(): ...@@ -6,7 +6,7 @@ for attachment in context.getAttachmentInformationList():
# Attachments # Attachments
if attachment['uid'] not in ['part_1', 'part_0']: if attachment['uid'] not in ['part_1', 'part_0']:
filename = context.getTitle() filename = context.getTitle()
if attachment.has_key("file_name"): if "file_name" in attachment:
filename=attachment["file_name"] filename=attachment["file_name"]
pt = "File" pt = "File"
temp_base_id = 'index_'.join([attachment["uid"], str(attachment["index"])]) temp_base_id = 'index_'.join([attachment["uid"], str(attachment["index"])])
......
...@@ -29,7 +29,7 @@ text_search_list = [] ...@@ -29,7 +29,7 @@ text_search_list = []
for text, prop_dict in context.getSearchableReferenceList(): for text, prop_dict in context.getSearchableReferenceList():
if text: if text:
text_search_list.append(text) text_search_list.append(text)
if prop_dict.has_key('reference'): if 'reference' in prop_dict:
reference_search_list.append(prop_dict['reference']) reference_search_list.append(prop_dict['reference'])
# Search reference ticket or project # Search reference ticket or project
......
...@@ -2007,7 +2007,7 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -2007,7 +2007,7 @@ class TestCRMMailSend(BaseTestCRM):
method_id='MailMessage_sendByActivity') method_id='MailMessage_sendByActivity')
self.commit() self.commit()
message_list = [i for i in portal_activities.getMessageList() \ message_list = [i for i in portal_activities.getMessageList() \
if i.kw.has_key("event_relative_url")] if "event_relative_url" in i.kw]
try: try:
# 5 recipients -> 5 activities # 5 recipients -> 5 activities
self.assertEqual(5, len(message_list)) self.assertEqual(5, len(message_list))
......
...@@ -193,44 +193,44 @@ class CrmTestCase(ERP5ReportTestCase): ...@@ -193,44 +193,44 @@ class CrmTestCase(ERP5ReportTestCase):
self.portal_categories = self.portal.portal_categories self.portal_categories = self.portal.portal_categories
# create group category # create group category
if not self.portal_categories['group'].has_key('demo_group'): if 'demo_group' not in self.portal_categories['group']:
group=self.portal_categories.group group=self.portal_categories.group
group.newContent(portal_type='Category', group.newContent(portal_type='Category',
title='demo_group', title='demo_group',
reference='demo_group', reference='demo_group',
id='demo_group') id='demo_group')
# create users and organisations # create users and organisations
if not self.person_module.has_key('Person_1'): if 'Person_1' not in self.person_module:
self.portal.person_module.newContent( self.portal.person_module.newContent(
portal_type='Person', portal_type='Person',
reference='Person_1', reference='Person_1',
title='Person_1', title='Person_1',
id='Person_1') id='Person_1')
if not self.person_module.has_key('Person_2'): if 'Person_2' not in self.person_module:
self.portal.person_module.newContent( self.portal.person_module.newContent(
portal_type='Person', portal_type='Person',
reference='Person_2', reference='Person_2',
title='Person_2', title='Person_2',
id='Person_2') id='Person_2')
if not self.person_module.has_key('Person_3'): if 'Person_3' not in self.person_module:
self.portal.person_module.newContent( self.portal.person_module.newContent(
portal_type='Person', portal_type='Person',
reference='Person_3', reference='Person_3',
title='Person_3', title='Person_3',
id='Person_3') id='Person_3')
if not self.organisation_module.has_key('Organisation_1'): if 'Organisation_1' not in self.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='Organisation_1', reference='Organisation_1',
title='Organisation_1', title='Organisation_1',
id='Organisation_1') id='Organisation_1')
if not self.organisation_module.has_key('Organisation_2'): if 'Organisation_2' not in self.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='Organisation_2', reference='Organisation_2',
title='Organisation_2', title='Organisation_2',
id='Organisation_2') id='Organisation_2')
if not self.organisation_module.has_key('My_organisation'): if 'My_organisation' not in self.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='My_organisation', reference='My_organisation',
......
...@@ -8,7 +8,7 @@ if object == None: ...@@ -8,7 +8,7 @@ if object == None:
# activity doesn't support security rights yet... # activity doesn't support security rights yet...
for key in ['uid','id']: for key in ['uid','id']:
if object_property_dict.has_key(key): if key in object_property_dict:
object_property_dict.pop(key) object_property_dict.pop(key)
object.edit(**object_property_dict) object.edit(**object_property_dict)
...@@ -12,7 +12,7 @@ else: ...@@ -12,7 +12,7 @@ else:
if discussion == None: if discussion == None:
return [] return []
if kw.has_key("portal_type") == False: if ("portal_type" in kw) == False:
kw['portal_type'] = "Discussion Post" kw['portal_type'] = "Discussion Post"
return discussion.searchFolder(**kw) return discussion.searchFolder(**kw)
"""This script returns the Discussion Thread list that is associated to this context. """This script returns the Discussion Thread list that is associated to this context.
Need a proxy to work correctly with anonymous user""" Need a proxy to work correctly with anonymous user"""
if not kw.has_key('portal_type'): if 'portal_type' not in kw:
kw["portal_type"] = "Discussion Thread" kw["portal_type"] = "Discussion Thread"
kw["follow_up_uid"] = context.getUid() kw["follow_up_uid"] = context.getUid()
......
...@@ -104,7 +104,7 @@ if newest not in BOOLEAN_MARKER: ...@@ -104,7 +104,7 @@ if newest not in BOOLEAN_MARKER:
search_mode = kw.get('search_mode', request.get('search_mode', None)) search_mode = kw.get('search_mode', request.get('search_mode', None))
search_mode_map={'in_boolean_mode':'boolean', search_mode_map={'in_boolean_mode':'boolean',
'with_query_expansion':'expanded'} 'with_query_expansion':'expanded'}
if search_mode not in MARKER and search_mode_map.has_key(search_mode): if search_mode not in MARKER and search_mode in search_mode_map:
search_string += ' mode:%s' % search_mode_map[search_mode] search_string += ' mode:%s' % search_mode_map[search_mode]
return search_string return search_string
...@@ -27,7 +27,7 @@ reference_search_list = [] ...@@ -27,7 +27,7 @@ reference_search_list = []
text_search_list = [] text_search_list = []
for text, prop_dict in context.getSearchableReferenceList(): for text, prop_dict in context.getSearchableReferenceList():
if text: text_search_list.append(text) if text: text_search_list.append(text)
if prop_dict.has_key('reference'): reference_search_list.append(prop_dict['reference']) if 'reference' in prop_dict: reference_search_list.append(prop_dict['reference'])
# Search reference ticket or project # Search reference ticket or project
follow_up_type_list = context.getPortalProjectTypeList() + context.getPortalTicketTypeList() follow_up_type_list = context.getPortalProjectTypeList() + context.getPortalTicketTypeList()
......
...@@ -31,7 +31,7 @@ default_sub_field_property_dict['field_type'] = 'ListField' ...@@ -31,7 +31,7 @@ default_sub_field_property_dict['field_type'] = 'ListField'
default_sub_field_property_dict['size'] = 1 default_sub_field_property_dict['size'] = 1
for base_category in item_list: for base_category in item_list:
if not sub_field_dict.has_key(base_category): if base_category not in sub_field_dict:
basecatobject = context.portal_categories.resolveCategory(base_category) basecatobject = context.portal_categories.resolveCategory(base_category)
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = base_category sub_field_property_dict['key'] = base_category
......
...@@ -37,12 +37,12 @@ for category_list in category_list_mapping.values(): ...@@ -37,12 +37,12 @@ for category_list in category_list_mapping.values():
#Take only needed attributes #Take only needed attributes
for attribute in translated_attributes_list: for attribute in translated_attributes_list:
#Test attribute exist #Test attribute exist
if category.has_key(attribute) and category.has_key(translation_prefix+attribute): if attribute in category and translation_prefix+attribute in category:
initial_value = category.get(attribute,'').strip().replace('"',"'") initial_value = category.get(attribute,'').strip().replace('"',"'")
if initial_value != '': if initial_value != '':
translate_value = category.get(translation_prefix+attribute,'').strip().replace('"',"'") translate_value = category.get(translation_prefix+attribute,'').strip().replace('"',"'")
if translate_value != '': if translate_value != '':
if translation_dict.has_key(initial_value): if initial_value in translation_dict:
#Test any duplicate translation ('car' can't be translated to 'voiture' and 'auto', #Test any duplicate translation ('car' can't be translated to 'voiture' and 'auto',
#user should be choice 'voiture' or 'car') #user should be choice 'voiture' or 'car')
if translation_dict[initial_value] != translate_value: if translation_dict[initial_value] != translate_value:
......
...@@ -40,7 +40,7 @@ for business_field in business_field_list: ...@@ -40,7 +40,7 @@ for business_field in business_field_list:
term_list = get_term_list(business_field, reference) term_list = get_term_list(business_field, reference)
#if not term_list: #if not term_list:
# continue # continue
if item_dict.has_key(field): if field in item_dict:
continue continue
item_dict[field] = True item_dict[field] = True
......
...@@ -43,7 +43,7 @@ for business_field in business_field_list: ...@@ -43,7 +43,7 @@ for business_field in business_field_list:
term_list = get_term_list(business_field, reference) term_list = get_term_list(business_field, reference)
#if not term_list: #if not term_list:
# continue # continue
if item_dict.has_key(wf_item): if wf_item in item_dict:
continue continue
item_dict[wf_item] = True item_dict[wf_item] = True
......
...@@ -36,7 +36,7 @@ for portal_type in portal_type_list: ...@@ -36,7 +36,7 @@ for portal_type in portal_type_list:
for x in remove_suffix_list: for x in remove_suffix_list:
if property_id.endswith(x): if property_id.endswith(x):
property_id = property_id[:-len(x)] property_id = property_id[:-len(x)]
if id_dict.has_key(property_id) or property_id in skip_id_list: if property_id in id_dict or property_id in skip_id_list:
continue continue
result.append({'reference':property_id, result.append({'reference':property_id,
'language':language, 'language':language,
......
...@@ -42,7 +42,7 @@ for business_field in template_list: ...@@ -42,7 +42,7 @@ for business_field in template_list:
term_list = get_term_list(business_field, reference) term_list = get_term_list(business_field, reference)
#if not term_list: #if not term_list:
# continue # continue
if item_dict.has_key(wf_item): if wf_item in item_dict:
continue continue
item_dict[wf_item] = True item_dict[wf_item] = True
......
...@@ -47,9 +47,9 @@ def iterate(document, skin_path): ...@@ -47,9 +47,9 @@ def iterate(document, skin_path):
form_id = field.get_value('form_id') form_id = field.get_value('form_id')
field_id = field.get_value('field_id') field_id = field.get_value('field_id')
key = "%s.%s" % (form_id, field_id) key = "%s.%s" % (form_id, field_id)
if to_rename_dict.has_key(key): if key in to_rename_dict:
field_path = "%s/%s/%s" % (skin_path, sub_object.id, field.id) field_path = "%s/%s/%s" % (skin_path, sub_object.id, field.id)
if selected_dict.has_key(field_path): if field_path in selected_dict:
unproxify_dict[field.id] = None unproxify_dict[field.id] = None
proxify_dict[field.id] = to_rename_dict[key] proxify_dict[field.id] = to_rename_dict[key]
next_preview_listbox.append( next_preview_listbox.append(
...@@ -83,7 +83,7 @@ if update: ...@@ -83,7 +83,7 @@ if update:
extra_kw = {} extra_kw = {}
for line in next_preview_listbox: for line in next_preview_listbox:
line["preview_listbox_key"] = "%03i" % count line["preview_listbox_key"] = "%03i" % count
line["selected"] = selected_dict.has_key(line["hidden_field_path"]) or preview_listbox is None line["selected"] = line["hidden_field_path"] in selected_dict or preview_listbox is None
extra_kw["field_preview_listbox_hidden_field_path_new_%03i" % count] = line["hidden_field_path"] extra_kw["field_preview_listbox_hidden_field_path_new_%03i" % count] = line["hidden_field_path"]
extra_kw["field_preview_listbox_selected_new_%03i" % count] = line["selected"] extra_kw["field_preview_listbox_selected_new_%03i" % count] = line["selected"]
count += 1 count += 1
......
...@@ -34,7 +34,7 @@ def callback(o,seldict): ...@@ -34,7 +34,7 @@ def callback(o,seldict):
form_name = o.absolute_url() # TODO it could be done much better form_name = o.absolute_url() # TODO it could be done much better
# assumes that name of form is unique enough # assumes that name of form is unique enough
form_name = form_name[form_name.rfind('/')+1:] form_name = form_name[form_name.rfind('/')+1:]
if seldict.has_key(field.get_value('selection_name')): if field.get_value('selection_name') in seldict:
old_list = seldict[field.get_value('selection_name')] old_list = seldict[field.get_value('selection_name')]
if form_name not in old_list: if form_name not in old_list:
old_list.append(form_name) old_list.append(form_name)
......
...@@ -146,7 +146,7 @@ except FormValidationError as validation_errors: ...@@ -146,7 +146,7 @@ except FormValidationError as validation_errors:
# Make sure editors are pushed back as values into the REQUEST object # Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields(): for f in form.get_fields():
field_id = f.id field_id = f.id
if request.has_key(field_id): if field_id in request:
value = request.get(field_id) value = request.get(field_id)
if callable(value): if callable(value):
value(request) value(request)
......
...@@ -47,7 +47,7 @@ except FormValidationError as validation_errors: ...@@ -47,7 +47,7 @@ except FormValidationError as validation_errors:
# Make sure editors are pushed back as values into the REQUEST object # Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields(): for f in form.get_fields():
field_id = f.id field_id = f.id
if request.has_key(field_id): if field_id in request:
value = request.get(field_id) value = request.get(field_id)
if callable(value): if callable(value):
value(request) value(request)
...@@ -179,11 +179,11 @@ def editMatrixBox(matrixbox_field, matrixbox): ...@@ -179,11 +179,11 @@ def editMatrixBox(matrixbox_field, matrixbox):
return "Could not create cell %s" % str(cell_index_tuple) return "Could not create cell %s" % str(cell_index_tuple)
cell.edit(edit_order=edit_order, **gv) # First update globals which include the def. of property_list cell.edit(edit_order=edit_order, **gv) # First update globals which include the def. of property_list
if cell_value_dict.has_key('variated_property'): if 'variated_property' in cell_value_dict:
# For Variated Properties # For Variated Properties
value = cell_value_dict['variated_property'] value = cell_value_dict['variated_property']
del cell_value_dict['variated_property'] del cell_value_dict['variated_property']
if gv.has_key('mapped_value_property_list'): if 'mapped_value_property_list' in gv:
# Change the property which is defined by the # Change the property which is defined by the
# first element of mapped_value_property_list # first element of mapped_value_property_list
# XXX Kato: What? Why? # XXX Kato: What? Why?
......
...@@ -1096,7 +1096,7 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti ...@@ -1096,7 +1096,7 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
selection_params=selection_params, selection_params=selection_params,
request_field=not use_relation_form_page_template, request_field=not use_relation_form_page_template,
form_relative_url=form_relative_url) form_relative_url=form_relative_url)
if field_errors.has_key(field.id): if field.id in field_errors:
response_dict[field.id]["error_text"] = field_errors[field.id].getMessage(Base_translateString) response_dict[field.id]["error_text"] = field_errors[field.id].getMessage(Base_translateString)
except AttributeError as error: except AttributeError as error:
# Do not crash if field configuration is wrong. # Do not crash if field configuration is wrong.
...@@ -2110,7 +2110,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -2110,7 +2110,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
value=default_field_value, value=default_field_value,
key='field_%s_%s' % (editable_field.id, brain_uid)) key='field_%s_%s' % (editable_field.id, brain_uid))
# Include cell error text in case of form validation # Include cell error text in case of form validation
if field_errors.has_key('%s_%s' % (editable_field.id, brain_uid)): if '%s_%s' % (editable_field.id, brain_uid) in field_errors:
contents_item[select]['field_gadget_param']["error_text"] = \ contents_item[select]['field_gadget_param']["error_text"] = \
Base_translateString(field_errors['%s_%s' % (editable_field.id, brain_uid)].error_text) Base_translateString(field_errors['%s_%s' % (editable_field.id, brain_uid)].error_text)
......
...@@ -941,7 +941,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -941,7 +941,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
'form_view' 'form_view'
) )
self.assertFalse(result_dict['_embedded']['_view'].has_key('_actions')) self.assertFalse('_actions' in result_dict['_embedded']['_view'])
@simulate('Base_getRequestUrl', '*args, **kwargs', @simulate('Base_getRequestUrl', '*args, **kwargs',
......
...@@ -1092,7 +1092,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase): ...@@ -1092,7 +1092,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase):
for key in e_period.keys(): for key in e_period.keys():
e_value = e_period[key] e_value = e_period[key]
#LOG('testing c_period %s "%s" value' % (e_period_cursor-1, key), 0, '') #LOG('testing c_period %s "%s" value' % (e_period_cursor-1, key), 0, '')
self.assertTrue(c_period.has_key(key)) self.assertTrue(key in c_period)
c_value = c_period[key] c_value = c_period[key]
is_float = 0 is_float = 0
try: try:
......
...@@ -12,7 +12,7 @@ if user is None: ...@@ -12,7 +12,7 @@ if user is None:
kw['owner'] = user kw['owner'] = user
kw['portal_type'] = context.getPortalMyDocumentTypeList() kw['portal_type'] = context.getPortalMyDocumentTypeList()
if not kw.has_key('validation_state'): if 'validation_state' not in kw:
kw['validation_state'] = "!=embedded" kw['validation_state'] = "!=embedded"
return context.portal_catalog.countResults(**kw) return context.portal_catalog.countResults(**kw)
...@@ -12,7 +12,7 @@ if user is None: ...@@ -12,7 +12,7 @@ if user is None:
kw['portal_type'] = context.getPortalMyDocumentTypeList() kw['portal_type'] = context.getPortalMyDocumentTypeList()
kw['owner'] = user kw['owner'] = user
if not kw.has_key('validation_state'): if 'validation_state' not in kw:
kw['validation_state'] = "!=embedded" kw['validation_state'] = "!=embedded"
return context.portal_catalog(**kw) return context.portal_catalog(**kw)
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Type-based. Type-based.
""" """
# convert language to lowercase # convert language to lowercase
if property_dict.has_key('language'): if 'language' in property_dict:
property_dict['language'] = property_dict['language'].lower() property_dict['language'] = property_dict['language'].lower()
language = property_dict.get('language', 'en') language = property_dict.get('language', 'en')
......
...@@ -167,7 +167,7 @@ class TestInvoiceMixin(TestPackingListMixin): ...@@ -167,7 +167,7 @@ class TestInvoiceMixin(TestPackingListMixin):
'product_line/apparel')) 'product_line/apparel'))
account_module = portal.account_module account_module = portal.account_module
for account_id, account_gap, account_type in self.account_definition_list: for account_id, account_gap, account_type in self.account_definition_list:
if not account_module.has_key(account_id): if account_id not in account_module:
account = account_module.newContent(account_id, gap=account_gap, account = account_module.newContent(account_id, gap=account_gap,
account_type=account_type) account_type=account_type)
account.validate() account.validate()
......
...@@ -35,7 +35,7 @@ for ss in source_section_list: ...@@ -35,7 +35,7 @@ for ss in source_section_list:
else: else:
uid = 'UID' uid = 'UID'
if not pl_dict.has_key(uid): if uid not in pl_dict:
pl_dict[uid] = module.newContent(**pl_property_dict) pl_dict[uid] = module.newContent(**pl_property_dict)
pl_dict[uid].setSourceSectionValue(ss) pl_dict[uid].setSourceSectionValue(ss)
......
...@@ -21,7 +21,7 @@ if dialog.has_field('your_item_extra_property_list'): ...@@ -21,7 +21,7 @@ if dialog.has_field('your_item_extra_property_list'):
for line in kw.get('listbox'): for line in kw.get('listbox'):
if line.has_key('listbox_key'): if 'listbox_key' in line:
item_reference = line.get('reference') item_reference = line.get('reference')
if item_reference: if item_reference:
item = context.portal_catalog.getResultValue( item = context.portal_catalog.getResultValue(
......
...@@ -21,7 +21,7 @@ kw = worklist.getIdentityCriterionDict() ...@@ -21,7 +21,7 @@ kw = worklist.getIdentityCriterionDict()
portal_type_list = workflow.getPortalTypeListForWorkflow() portal_type_list = workflow.getPortalTypeListForWorkflow()
if not portal_type_list: if not portal_type_list:
return {} # If no portal type uses the workflow, ignore it return {} # If no portal type uses the workflow, ignore it
if not kw.has_key('portal_type'): if 'portal_type' not in kw:
# Set portal types which use the workflow # Set portal types which use the workflow
kw['portal_type'] = portal_type_list kw['portal_type'] = portal_type_list
......
...@@ -28,7 +28,7 @@ def getWebSectionPredicateValueList(): ...@@ -28,7 +28,7 @@ def getWebSectionPredicateValueList():
# remove leading 'follow_up' from category # remove leading 'follow_up' from category
if category.startswith('follow_up/'): if category.startswith('follow_up/'):
category = category.replace('follow_up/', '', 1) category = category.replace('follow_up/', '', 1)
if not category_map.has_key(category): if category not in category_map:
category_map[category] = [] category_map[category] = []
category_map[category].append({'uid': section['uid'], 'relative_url':section['relative_url']}) category_map[category].append({'uid': section['uid'], 'relative_url':section['relative_url']})
# get base_categories we care for # get base_categories we care for
......
...@@ -25,7 +25,7 @@ except FormValidationError, validation_errors: ...@@ -25,7 +25,7 @@ except FormValidationError, validation_errors:
# Make sure editors are pushed back as values into the REQUEST object # Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields(): for f in form.get_fields():
field_id = f.id field_id = f.id
if request.has_key(field_id): if field_id in request:
value = request.get(field_id) value = request.get(field_id)
if callable(value): if callable(value):
value(request) value(request)
......
...@@ -7,7 +7,7 @@ result_listbox = [] ...@@ -7,7 +7,7 @@ result_listbox = []
# context.log(str(kw)) # context.log(str(kw))
if active_process_path is None: if active_process_path is None:
if kw.has_key('active_process') and kw['active_process'] not in ('', None): if 'active_process' in kw and kw['active_process'] not in ('', None):
active_process_path = kw['active_process'] active_process_path = kw['active_process']
#else: #else:
# if context.REQUEST.get('active_process', None) not in ('None', None): # if context.REQUEST.get('active_process', None) not in ('None', None):
......
...@@ -108,7 +108,7 @@ else: ...@@ -108,7 +108,7 @@ else:
portal_type, property = portal_type_property.split('.', 1) portal_type, property = portal_type_property.split('.', 1)
if not mapping.has_key(spreadsheet_name): if spreadsheet_name not in mapping:
mapping[spreadsheet_name] = (portal_type, {}) mapping[spreadsheet_name] = (portal_type, {})
mapping[spreadsheet_name][1][column_name] = property mapping[spreadsheet_name][1][column_name] = property
...@@ -147,7 +147,7 @@ else: ...@@ -147,7 +147,7 @@ else:
imported_line_property_dict = {} imported_line_property_dict = {}
for line_property_index in range(len(line)): for line_property_index in range(len(line)):
if column_mapping.has_key(line_property_index): if line_property_index in column_mapping:
property_value = line[line_property_index] property_value = line[line_property_index]
if property_value: if property_value:
# Create a new property value # Create a new property value
......
...@@ -94,7 +94,7 @@ class PaypalService(XMLObject): ...@@ -94,7 +94,7 @@ class PaypalService(XMLObject):
param_dict = REQUEST.form param_dict = REQUEST.form
LOG("PaypalService", DEBUG, param_dict) LOG("PaypalService", DEBUG, param_dict)
param_dict["cmd"] = "_notify-validate" param_dict["cmd"] = "_notify-validate"
if param_dict.has_key("service"): if "service" in param_dict:
param_dict.pop("service") param_dict.pop("service")
param_list = urlencode(param_dict) param_list = urlencode(param_dict)
paypal_url = self.getLinkUrlString() paypal_url = self.getLinkUrlString()
......
...@@ -199,7 +199,7 @@ class PaySheetTransaction(Invoice): ...@@ -199,7 +199,7 @@ class PaySheetTransaction(Invoice):
if movement.getTotalPrice() not in (0, None): if movement.getTotalPrice() not in (0, None):
# remove movement with 0 total_price # remove movement with 0 total_price
trade_phase = movement.getTradePhase() trade_phase = movement.getTradePhase()
if not movement_list_trade_phase_dic.has_key(trade_phase): if trade_phase not in movement_list_trade_phase_dic:
movement_list_trade_phase_dic[trade_phase] = [] movement_list_trade_phase_dic[trade_phase] = []
movement_list_trade_phase_dic[trade_phase].append(movement) movement_list_trade_phase_dic[trade_phase].append(movement)
for trade_phase in movement_list_trade_phase_dic.keys(): for trade_phase in movement_list_trade_phase_dic.keys():
......
...@@ -14,7 +14,7 @@ context.manage_delObjects(id_list) ...@@ -14,7 +14,7 @@ context.manage_delObjects(id_list)
# create Pay Sheet Lines # create Pay Sheet Lines
context.createPaySheetLineList(listbox=listbox) context.createPaySheetLineList(listbox=listbox)
if not(kw.has_key('skip_redirect') and kw['skip_redirect'] == True): if not('skip_redirect' in kw and kw['skip_redirect'] == True):
# Return to pay sheet default view # Return to pay sheet default view
from ZTUtils import make_query from ZTUtils import make_query
redirect_url = '%s/%s?%s' % (context.absolute_url(), 'view', make_query()) redirect_url = '%s/%s?%s' % (context.absolute_url(), 'view', make_query())
......
...@@ -80,10 +80,10 @@ for model_line in model_line_list: ...@@ -80,10 +80,10 @@ for model_line in model_line_list:
salary_range = 'no_slice' salary_range = 'no_slice'
# check that another share on the same slice have not been already add # check that another share on the same slice have not been already add
if not object_dict.has_key(salary_range): if salary_range not in object_dict:
salary_range_title = None salary_range_title = None
salary_range_relative_url = None salary_range_relative_url = None
if tuple_dict.has_key('salary_range'): if 'salary_range' in tuple_dict:
salary_range_title = tuple_dict['salary_range'] salary_range_title = tuple_dict['salary_range']
salary_range_relative_url = tuple_dict['salary_range_relative_url'] salary_range_relative_url = tuple_dict['salary_range_relative_url']
new_uid = "new_%s" % id_ new_uid = "new_%s" % id_
...@@ -108,7 +108,7 @@ for model_line in model_line_list: ...@@ -108,7 +108,7 @@ for model_line in model_line_list:
for object_key in model_line.getSalaryRangeList(): for object_key in model_line.getSalaryRangeList():
line_list.append(model_line.asContext(**object_dict[object_key])) line_list.append(model_line.asContext(**object_dict[object_key]))
if object_dict.has_key('no_slice'): if 'no_slice' in object_dict:
line_list.append(model_line.asContext(**object_dict['no_slice'])) line_list.append(model_line.asContext(**object_dict['no_slice']))
...@@ -132,7 +132,7 @@ def sortByIntIndexDescending(x, y): ...@@ -132,7 +132,7 @@ def sortByIntIndexDescending(x, y):
sortByDefaultSortMethod = sortByIntIndexAscending sortByDefaultSortMethod = sortByIntIndexAscending
if kw.has_key('sort_on'): if 'sort_on' in kw:
sort_on = kw['sort_on'] sort_on = kw['sort_on']
if sort_on[0][0] == 'title' and sort_on[0][1]=='ascending': if sort_on[0][0] == 'title' and sort_on[0][1]=='ascending':
line_list.sort(sortByTitleAscending) line_list.sort(sortByTitleAscending)
......
...@@ -78,9 +78,9 @@ for paysheet_line in paysheet_line_list: ...@@ -78,9 +78,9 @@ for paysheet_line in paysheet_line_list:
salary_range_slice = cell.getSalaryRange() salary_range_slice = cell.getSalaryRange()
if salary_range_slice is None: if salary_range_slice is None:
salary_range_slice = 'no_slice' salary_range_slice = 'no_slice'
if not object_dict.has_key(salary_range_slice): if salary_range_slice not in object_dict:
slice_title = None slice_title = None
if tuple_dict.has_key('salary_range'): if 'salary_range' in tuple_dict:
slice_title=tuple_dict['salary_range'] slice_title=tuple_dict['salary_range']
object_dict[salary_range_slice]={ object_dict[salary_range_slice]={
'slice':slice_title, 'slice':slice_title,
...@@ -117,7 +117,7 @@ for paysheet_line in paysheet_line_list: ...@@ -117,7 +117,7 @@ for paysheet_line in paysheet_line_list:
for object_key in paysheet_line.getSalaryRangeList(): for object_key in paysheet_line.getSalaryRangeList():
line_list.append(paysheet_line.asContext(**object_dict[object_key])) line_list.append(paysheet_line.asContext(**object_dict[object_key]))
if object_dict.has_key('no_slice'): if 'no_slice' in object_dict:
line_list.append(paysheet_line.asContext(**object_dict['no_slice'])) line_list.append(paysheet_line.asContext(**object_dict['no_slice']))
...@@ -137,7 +137,7 @@ def sortByIntIndexDescending(x, y): ...@@ -137,7 +137,7 @@ def sortByIntIndexDescending(x, y):
sortByDefaultSortMethod = sortByIntIndexAscending sortByDefaultSortMethod = sortByIntIndexAscending
if kw.has_key('sort_on'): if 'sort_on' in kw:
sort_on = kw['sort_on'] sort_on = kw['sort_on']
if sort_on[0][0] == 'title' and sort_on[0][1]=='ascending': if sort_on[0][0] == 'title' and sort_on[0][1]=='ascending':
line_list.sort(sortByTitleAscending) line_list.sort(sortByTitleAscending)
......
...@@ -22,14 +22,14 @@ for line in line_dict_list: ...@@ -22,14 +22,14 @@ for line in line_dict_list:
string_to_display.append(rightPad(line['title'], 40)) string_to_display.append(rightPad(line['title'], 40))
string_to_display.append(rightPad(line['base'], 16)) string_to_display.append(rightPad(line['base'], 16))
if line.has_key('employer_quantity'): if 'employer_quantity' in line:
string_to_display.append(rightPad(str(line['employer_price']), 24)) string_to_display.append(rightPad(str(line['employer_price']), 24))
string_to_display.append(rightPad(str(line['employer_quantity']), 24)) string_to_display.append(rightPad(str(line['employer_quantity']), 24))
else: else:
string_to_display.append(rightPad(' ', 24)) string_to_display.append(rightPad(' ', 24))
string_to_display.append(rightPad(' ', 24)) string_to_display.append(rightPad(' ', 24))
if line.has_key('employee_quantity'): if 'employee_quantity' in line:
string_to_display.append(rightPad(str(line['employee_price']), 24)) string_to_display.append(rightPad(str(line['employee_price']), 24))
string_to_display.append(rightPad(str(line['employee_quantity']), 24)) string_to_display.append(rightPad(str(line['employee_quantity']), 24))
else: else:
......
...@@ -1428,16 +1428,16 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1428,16 +1428,16 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
self.assertEqual(len(model_reference_dict), 3) # there is 4 model but two self.assertEqual(len(model_reference_dict), 3) # there is 4 model but two
# models have the same # models have the same
# reference. # reference.
self.assertEqual(model_reference_dict.has_key(model_employee_url), True) self.assertEqual(model_employee_url in model_reference_dict, True)
self.assertEqual(model_reference_dict[model_employee_url], self.assertEqual(model_reference_dict[model_employee_url],
['over_time_duration']) ['over_time_duration'])
self.assertEqual(model_reference_dict.has_key(model_company_url), True) self.assertEqual(model_company_url in model_reference_dict, True)
self.assertEqual(model_reference_dict[model_company_url], self.assertEqual(model_reference_dict[model_company_url],
['worked_time_duration']) ['worked_time_duration'])
self.assertEqual(model_reference_dict.has_key(model_company_alt_url), True) self.assertEqual(model_company_alt_url in model_reference_dict, True)
self.assertEqual(model_reference_dict[model_company_alt_url], self.assertEqual(model_reference_dict[model_company_alt_url],
['social_insurance']) ['social_insurance'])
self.assertNotEquals(model_reference_dict.has_key(model_country_url), True) self.assertNotEquals(model_country_url in model_reference_dict, True)
# check the object list : # check the object list :
object_list = paysheet.getInheritedObjectValueList(portal_type_list=\ object_list = paysheet.getInheritedObjectValueList(portal_type_list=\
......
...@@ -14,7 +14,7 @@ for item in item_list: ...@@ -14,7 +14,7 @@ for item in item_list:
item_split = string.split(item_value, '/') item_split = string.split(item_value, '/')
item_key = string.join(item_split[:split_depth] , '/' ) item_key = string.join(item_split[:split_depth] , '/' )
base_category = item_split[0] base_category = item_split[0]
if not sub_field_dict.has_key(item_key): if item_key not in sub_field_dict:
# Create property dict # Create property dict
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key sub_field_property_dict['key'] = item_key
......
...@@ -14,7 +14,7 @@ result = [] ...@@ -14,7 +14,7 @@ result = []
variation_category_dict = {} variation_category_dict = {}
for variation_category in reference_variation_category_list: for variation_category in reference_variation_category_list:
base_category = variation_category.split('/',1)[0] base_category = variation_category.split('/',1)[0]
if variation_category_dict.has_key( base_category ): if base_category in variation_category_dict:
variation_category_dict[base_category].append( variation_category ) variation_category_dict[base_category].append( variation_category )
else: else:
variation_category_dict[base_category] = [variation_category] variation_category_dict[base_category] = [variation_category]
......
...@@ -14,7 +14,7 @@ for item in item_list: ...@@ -14,7 +14,7 @@ for item in item_list:
item_split = string.split(item_value, '/') item_split = string.split(item_value, '/')
item_key = string.join(item_split[:split_depth] , '/' ) item_key = string.join(item_split[:split_depth] , '/' )
if not sub_field_dict.has_key(item_key): if item_key not in sub_field_dict:
# Create property dict # Create property dict
sub_field_property_dict = default_sub_field_property_dict.copy() sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key sub_field_property_dict['key'] = item_key
......
...@@ -14,7 +14,7 @@ task_items = [] ...@@ -14,7 +14,7 @@ task_items = []
# get the user information # get the user information
for task in listbox: for task in listbox:
if task.has_key('listbox_key'): if 'listbox_key' in task:
task_id = int(task['listbox_key']) task_id = int(task['listbox_key'])
task_dict = {} task_dict = {}
task_dict['id'] = task_id task_dict['id'] = task_id
......
...@@ -54,7 +54,7 @@ else: ...@@ -54,7 +54,7 @@ else:
project_to_display_dict = here.monthly_project_to_display_dict.get(string_index, {}) project_to_display_dict = here.monthly_project_to_display_dict.get(string_index, {})
if depth == 1: if depth == 1:
category_list = [here.project_dict[x] for x in project_to_display_dict.keys() if category_list = [here.project_dict[x] for x in project_to_display_dict.keys() if
here.project_dict.has_key(x)] x in here.project_dict]
else: else:
parent_category_list = parent.getMembershipCriterionCategoryList() parent_category_list = parent.getMembershipCriterionCategoryList()
category_list = [] category_list = []
...@@ -63,12 +63,12 @@ else: ...@@ -63,12 +63,12 @@ else:
# need to be displayed for this month # need to be displayed for this month
for parent_category in parent_category_list: for parent_category in parent_category_list:
parent_category = '/'.join(parent_category.split('/')[1:]) parent_category = '/'.join(parent_category.split('/')[1:])
if project_to_display_dict.has_key(parent_category): if parent_category in project_to_display_dict:
parent_category_object = context.restrictedTraverse(parent_category) parent_category_object = context.restrictedTraverse(parent_category)
category_child_list = parent_category_object.contentValues(portal_type=project_line_portal_type) category_child_list = parent_category_object.contentValues(portal_type=project_line_portal_type)
#category_list.append(parent_category_object) #category_list.append(parent_category_object)
for category_child in category_child_list: for category_child in category_child_list:
if project_to_display_dict.has_key(category_child.getRelativeUrl()): if category_child.getRelativeUrl() in project_to_display_dict:
category_list.append(category_child) category_list.append(category_child)
......
...@@ -37,7 +37,7 @@ def getTotalQuantity(line,worker): ...@@ -37,7 +37,7 @@ def getTotalQuantity(line,worker):
for child in child_list: for child in child_list:
child_quantity = getTotalQuantity(child,worker) child_quantity = getTotalQuantity(child,worker)
for key,value in child_quantity.items(): for key,value in child_quantity.items():
if not quantity.has_key(key): if key not in quantity:
quantity[key] = 0 quantity[key] = 0
quantity[key] = quantity[key] + value quantity[key] = quantity[key] + value
else: else:
...@@ -73,7 +73,7 @@ for year,month in month_list: ...@@ -73,7 +73,7 @@ for year,month in month_list:
listbox_line['month'] = month listbox_line['month'] = month
for worker in worker_list: for worker in worker_list:
quantity = 0 quantity = 0
if worker_quantity[worker].has_key((year,month)): if (year,month) in worker_quantity[worker]:
quantity = worker_quantity[worker][(year,month)] quantity = worker_quantity[worker][(year,month)]
worker_title = 'unknown' worker_title = 'unknown'
if worker is not None: if worker is not None:
......
...@@ -25,6 +25,6 @@ else: ...@@ -25,6 +25,6 @@ else:
membership_criterion_category = membership_criterion_category_list[0] membership_criterion_category = membership_criterion_category_list[0]
assert membership_criterion_category.startswith('source_project/') assert membership_criterion_category.startswith('source_project/')
project_relative_url = membership_criterion_category[len('source_project/'):] project_relative_url = membership_criterion_category[len('source_project/'):]
if returned_object.has_key(project_relative_url): if project_relative_url in returned_object:
result_list.append(returned_object[project_relative_url]) result_list.append(returned_object[project_relative_url])
return result_list return result_list
...@@ -127,7 +127,7 @@ for task_line in result_list: ...@@ -127,7 +127,7 @@ for task_line in result_list:
project_relative_url = project_dict['relative_url'] project_relative_url = project_dict['relative_url']
full_date_total_worker_quantity_dict[source_relative_url] = \ full_date_total_worker_quantity_dict[source_relative_url] = \
full_date_total_worker_quantity_dict.get(source_relative_url, 0) + quantity full_date_total_worker_quantity_dict.get(source_relative_url, 0) + quantity
if not full_date_total_object_dict.has_key(project_relative_url): if project_relative_url not in full_date_total_object_dict:
temp_object = temp_object_container.newContent(portal_type = 'Project Line', temp_object = temp_object_container.newContent(portal_type = 'Project Line',
temp_object=1, temp_object=1,
string_index = full_date_string, string_index = full_date_string,
...@@ -153,7 +153,7 @@ for task_line in result_list: ...@@ -153,7 +153,7 @@ for task_line in result_list:
project_to_display_dict = monthly_project_to_display_dict.setdefault(string_index, {}) project_to_display_dict = monthly_project_to_display_dict.setdefault(string_index, {})
fillDictWithParentAndChildRelativeUrls(project_to_display_dict, project_relative_url) fillDictWithParentAndChildRelativeUrls(project_to_display_dict, project_relative_url)
if not quantity_dict.has_key(project_relative_url): if project_relative_url not in quantity_dict:
temp_object = temp_object_container.newContent(portal_type = 'Project Line', temp_object = temp_object_container.newContent(portal_type = 'Project Line',
temp_object=1, temp_object=1,
string_index = string_index, string_index = string_index,
......
...@@ -4,15 +4,15 @@ source_project_uid_list = [x.uid for x in context.portal_catalog( ...@@ -4,15 +4,15 @@ source_project_uid_list = [x.uid for x in context.portal_catalog(
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import Query
sql_kw = {} sql_kw = {}
if kw.has_key('from_date') and kw['from_date'] is not None: if 'from_date' in kw and kw['from_date'] is not None:
query_kw = {'delivery.start_date' : kw['from_date'], query_kw = {'delivery.start_date' : kw['from_date'],
'range' : 'min'} 'range' : 'min'}
sql_kw['delivery.start_date'] = Query(**query_kw) sql_kw['delivery.start_date'] = Query(**query_kw)
if kw.has_key('at_date') and kw['at_date'] is not None: if 'at_date' in kw and kw['at_date'] is not None:
query_kw = {'delivery.stop_date' : kw['at_date'], query_kw = {'delivery.stop_date' : kw['at_date'],
'range' : 'ngt'} 'range' : 'ngt'}
sql_kw['delivery.stop_date'] = Query(**query_kw) sql_kw['delivery.stop_date'] = Query(**query_kw)
if kw.has_key('simulation_state') and len(kw['simulation_state']) > 0 : if 'simulation_state' in kw and len(kw['simulation_state']) > 0 :
sql_kw['simulation_state'] = kw['simulation_state'] sql_kw['simulation_state'] = kw['simulation_state']
task_list = [x.getObject() for x in \ task_list = [x.getObject() for x in \
......
...@@ -4,18 +4,18 @@ source_project_uid_list = [x.uid for x in context.portal_catalog( ...@@ -4,18 +4,18 @@ source_project_uid_list = [x.uid for x in context.portal_catalog(
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import Query
sql_kw = {} sql_kw = {}
if kw.has_key('from_date') and kw['from_date'] is not None: if 'from_date' in kw and kw['from_date'] is not None:
query_kw = {'delivery.start_date' : kw['from_date'], query_kw = {'delivery.start_date' : kw['from_date'],
'range' : 'min'} 'range' : 'min'}
sql_kw['delivery.start_date'] = Query(**query_kw) sql_kw['delivery.start_date'] = Query(**query_kw)
if kw.has_key('at_date') and kw['at_date'] is not None: if 'at_date' in kw and kw['at_date'] is not None:
query_kw = {'delivery.stop_date' : kw['at_date'], query_kw = {'delivery.stop_date' : kw['at_date'],
'range' : 'ngt'} 'range' : 'ngt'}
sql_kw['delivery.stop_date'] = Query(**query_kw) sql_kw['delivery.stop_date'] = Query(**query_kw)
# Make sure to not include "confirmed tasks" in any case, because in # Make sure to not include "confirmed tasks" in any case, because in
# this case we must take task reports # this case we must take task reports
if kw.has_key('simulation_state') and len(kw['simulation_state']) > 0 : if 'simulation_state' in kw and len(kw['simulation_state']) > 0 :
task_simulation_state = [x for x in kw['simulation_state'] if x != 'confirmed'] task_simulation_state = [x for x in kw['simulation_state'] if x != 'confirmed']
task_report_simulation_state = kw['simulation_state'] task_report_simulation_state = kw['simulation_state']
else: else:
......
...@@ -26,7 +26,7 @@ requirements_items = [] ...@@ -26,7 +26,7 @@ requirements_items = []
# get the user information # get the user information
for requirement_line in listbox: for requirement_line in listbox:
if requirement_line.has_key('listbox_key'): if 'listbox_key' in requirement_line:
requirement_line_id = int(requirement_line['listbox_key']) requirement_line_id = int(requirement_line['listbox_key'])
requirement = {} requirement = {}
requirement['id'] = requirement_line_id requirement['id'] = requirement_line_id
...@@ -76,7 +76,7 @@ for requirement_item in requirements_items: ...@@ -76,7 +76,7 @@ for requirement_item in requirements_items:
new_1st_level_requirement.append(new_2nd_level_feat) new_1st_level_requirement.append(new_2nd_level_feat)
if has_1st_level_requirement: if has_1st_level_requirement:
if clean_requirements.has_key(new_1st_level_requirement_title): if new_1st_level_requirement_title in clean_requirements:
new_1st_level_requirement = clean_requirements[new_1st_level_requirement_title] + new_1st_level_requirement new_1st_level_requirement = clean_requirements[new_1st_level_requirement_title] + new_1st_level_requirement
clean_requirements[new_1st_level_requirement_title] = new_1st_level_requirement clean_requirements[new_1st_level_requirement_title] = new_1st_level_requirement
clean_requirements_key_list.append(new_1st_level_requirement_title) clean_requirements_key_list.append(new_1st_level_requirement_title)
......
...@@ -3,7 +3,7 @@ log('task_list','starting') ...@@ -3,7 +3,7 @@ log('task_list','starting')
task_module = context.getDefaultModule('Task Report') task_module = context.getDefaultModule('Task Report')
log('task_list','next1') log('task_list','next1')
task_list = [] task_list = []
if not kw.has_key('parent_uid'): if 'parent_uid' not in kw:
kw['parent_uid'] = task_module.getUid() kw['parent_uid'] = task_module.getUid()
log('task_list','next2') log('task_list','next2')
log('context.getPath()',context.getPath()) log('context.getPath()',context.getPath())
......
obj_len = len(context.objectValues(portal_type=("Task Line", "Task Report Line"))) obj_len = len(context.objectValues(portal_type=("Task Line", "Task Report Line")))
return (obj_len == 0) or ((obj_len == 1) and context.has_key('default_task_line')) return (obj_len == 0) or ((obj_len == 1) and 'default_task_line' in context)
...@@ -62,18 +62,18 @@ class TestProject(ERP5TypeTestCase): ...@@ -62,18 +62,18 @@ class TestProject(ERP5TypeTestCase):
rule.validate() rule.validate()
# create organisations # create organisations
if not self.portal.organisation_module.has_key('Organisation_1'): if 'Organisation_1' not in self.portal.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
title='Organisation_1', title='Organisation_1',
id='Organisation_1') id='Organisation_1')
# create organisations # create organisations
if not self.portal.organisation_module.has_key('Organisation_2'): if 'Organisation_2' not in self.portal.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
title='Organisation_2', title='Organisation_2',
id='Organisation_2') id='Organisation_2')
# create project # create project
if not self.portal.project_module.has_key('Project_1'): if 'Project_1' not in self.portal.project_module:
self.portal.project_module.newContent( self.portal.project_module.newContent(
portal_type='Project', portal_type='Project',
reference='Project_1', reference='Project_1',
...@@ -82,7 +82,7 @@ class TestProject(ERP5TypeTestCase): ...@@ -82,7 +82,7 @@ class TestProject(ERP5TypeTestCase):
# Create resources # Create resources
module = self.portal.product_module module = self.portal.product_module
if not module.has_key('development'): if 'development' not in module:
module.newContent( module.newContent(
portal_type='Product', portal_type='Product',
id='development', id='development',
......
...@@ -71,14 +71,14 @@ class TestTaskReportingMixin(ERP5ReportTestCase): ...@@ -71,14 +71,14 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
rule.validate() rule.validate()
# create organisations # create organisations
if not self.portal.organisation_module.has_key('Organisation_1'): if 'Organisation_1' not in self.portal.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='Organisation_1', reference='Organisation_1',
title='Organisation_1', title='Organisation_1',
id='Organisation_1') id='Organisation_1')
if not self.portal.organisation_module.has_key('Organisation_2'): if 'Organisation_2' not in self.portal.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='Organisation_2', reference='Organisation_2',
...@@ -86,13 +86,13 @@ class TestTaskReportingMixin(ERP5ReportTestCase): ...@@ -86,13 +86,13 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
id='Organisation_2') id='Organisation_2')
# create persons # create persons
if not self.portal.person_module.has_key('Person_1'): if 'Person_1' not in self.portal.person_module:
self.portal.person_module.newContent( self.portal.person_module.newContent(
portal_type='Person', portal_type='Person',
reference='Person_1', reference='Person_1',
title='Person_1', title='Person_1',
id='Person_1') id='Person_1')
if not self.portal.person_module.has_key('Person_2'): if 'Person_2' not in self.portal.person_module:
self.portal.person_module.newContent( self.portal.person_module.newContent(
portal_type='Person', portal_type='Person',
reference='Person_2', reference='Person_2',
...@@ -100,7 +100,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase): ...@@ -100,7 +100,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
id='Person_2') id='Person_2')
# create project # create project
if not self.portal.project_module.has_key('Project_1'): if 'Project_1' not in self.portal.project_module:
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project', portal_type='Project',
reference='Project_1', reference='Project_1',
...@@ -114,7 +114,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase): ...@@ -114,7 +114,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
project.newContent(portal_type='Project Line', project.newContent(portal_type='Project Line',
id='Line_2', id='Line_2',
title='Line_2') title='Line_2')
if not self.portal.project_module.has_key('Project_2'): if 'Project_2' not in self.portal.project_module:
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project', portal_type='Project',
reference='Project_2', reference='Project_2',
...@@ -125,7 +125,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase): ...@@ -125,7 +125,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
# create unit categories # create unit categories
for unit_id in ('day', 'hour',): for unit_id in ('day', 'hour',):
if not self.portal.portal_categories['quantity_unit'].has_key(unit_id): if unit_id not in self.portal.portal_categories['quantity_unit']:
self.portal.portal_categories.quantity_unit.newContent( self.portal.portal_categories.quantity_unit.newContent(
portal_type='Category', portal_type='Category',
title=unit_id.title(), title=unit_id.title(),
...@@ -134,7 +134,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase): ...@@ -134,7 +134,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
# Create resources # Create resources
module = self.portal.product_module module = self.portal.product_module
if not module.has_key('development'): if 'development' not in module:
module.newContent( module.newContent(
portal_type='Product', portal_type='Product',
id='development', id='development',
...@@ -142,7 +142,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase): ...@@ -142,7 +142,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
reference='ref 1', reference='ref 1',
quantity_unit='day' quantity_unit='day'
) )
if not module.has_key('consulting'): if 'consulting' not in module:
module.newContent( module.newContent(
portal_type='Product', portal_type='Product',
id='consulting', id='consulting',
......
...@@ -42,16 +42,16 @@ class TestResearchItemSummaryReport(TestTaskReportingMixin): ...@@ -42,16 +42,16 @@ class TestResearchItemSummaryReport(TestTaskReportingMixin):
super(TestResearchItemSummaryReport, self).afterSetUp() super(TestResearchItemSummaryReport, self).afterSetUp()
ledger_base_category = self.portal.portal_categories.ledger ledger_base_category = self.portal.portal_categories.ledger
for category_id in ("operation", "research"): for category_id in ("operation", "research"):
if not ledger_base_category.has_key(category_id): if category_id not in ledger_base_category:
ledger_base_category.newContent( ledger_base_category.newContent(
portal_type='Category', title=category_id.title(), portal_type='Category', title=category_id.title(),
reference=category_id, id=category_id) reference=category_id, id=category_id)
# create items # create items
if not self.portal.research_item_module.has_key('Item_1'): if 'Item_1' not in self.portal.research_item_module:
self.portal.research_item_module.newContent(title="Item_1", self.portal.research_item_module.newContent(title="Item_1",
id="Item_1", portal_type="Research Item") id="Item_1", portal_type="Research Item")
if not self.portal.research_item_module.has_key('Item_2'): if 'Item_2' not in self.portal.research_item_module:
self.portal.research_item_module.newContent(title="Item_2", self.portal.research_item_module.newContent(title="Item_2",
id="Item_2", portal_type="Research Item") id="Item_2", portal_type="Research Item")
......
...@@ -11,7 +11,7 @@ if image_caption in [None, ""]: ...@@ -11,7 +11,7 @@ if image_caption in [None, ""]:
image_caption = chapter_title image_caption = chapter_title
session = context.ERP5Site_acquireRunMyDocsSession() session = context.ERP5Site_acquireRunMyDocsSession()
if session.has_key('listbox') and len(session['listbox']) > 0: if 'listbox' in session and len(session['listbox']) > 0:
listbox = session['listbox'] listbox = session['listbox']
int_index = listbox[-1].int_index + 1 int_index = listbox[-1].int_index + 1
else: else:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
""" """
session = context.ERP5Site_acquireRunMyDocsSession() session = context.ERP5Site_acquireRunMyDocsSession()
if session.has_key('listbox'): if 'listbox' in session:
listbox = session['listbox'] listbox = session['listbox']
else: else:
listbox = [] listbox = []
......
...@@ -444,7 +444,7 @@ class TestBPMImplementation(TestBPMDummyDeliveryMovementMixin): ...@@ -444,7 +444,7 @@ class TestBPMImplementation(TestBPMDummyDeliveryMovementMixin):
context_movement = self.createMovement() context_movement = self.createMovement()
self.assertEqual(None, business_path.getSourceValue()) self.assertEqual(None, business_path.getSourceValue())
self.assertFalse(business_path.getArrowCategoryDict(context=context_movement).has_key('source')) self.assertFalse('source' in business_path.getArrowCategoryDict(context=context_movement))
def test_BusinessPathDynamicCategoryAccessProviderReplaceCategory(self): def test_BusinessPathDynamicCategoryAccessProviderReplaceCategory(self):
business_path = self.createTradeModelPath() business_path = self.createTradeModelPath()
......
...@@ -112,7 +112,7 @@ class SyncMLSubscription(XMLObject): ...@@ -112,7 +112,7 @@ class SyncMLSubscription(XMLObject):
activate_kw : activity parameters to pass to activate call activate_kw : activity parameters to pass to activate call
kw : any parameter getAndActivate can required if it calls itself kw : any parameter getAndActivate can required if it calls itself
""" """
if kw.has_key("packet_size"): if "packet_size" in kw:
search_kw = dict(kw) search_kw = dict(kw)
packet_size = search_kw.pop('packet_size', 30) packet_size = search_kw.pop('packet_size', 30)
limit = packet_size * search_kw.pop('activity_count', 100) limit = packet_size * search_kw.pop('activity_count', 100)
...@@ -277,7 +277,7 @@ class SyncMLSubscription(XMLObject): ...@@ -277,7 +277,7 @@ class SyncMLSubscription(XMLObject):
syncml_logger.debug("--> calling getAndActivate packet size = %s, limit = %s", syncml_logger.debug("--> calling getAndActivate packet size = %s, limit = %s",
packet_size, limit) packet_size, limit)
# We must know if we have a lower limit or not to propagate # We must know if we have a lower limit or not to propagate
if not kw.has_key("strict_min_gid"): if "strict_min_gid" not in kw:
first_call = True first_call = True
else: else:
first_call = False first_call = False
......
...@@ -292,7 +292,7 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -292,7 +292,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
* machin = getattr (object, methos) * machin = getattr (object, methos)
* machin() * machin()
""" """
if kw.has_key(key): if key in kw:
new_value = kw[key] new_value = kw[key]
if new_value != None: if new_value != None:
if isinstance(new_value, str): if isinstance(new_value, str):
...@@ -338,7 +338,7 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -338,7 +338,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
erp5_site_path = erp5_site.absolute_url(relative=1) erp5_site_path = erp5_site.absolute_url(relative=1)
# The object is a ShopOrder # The object is a ShopOrder
if kw.has_key('country'): if 'country' in kw:
object.setStartDate(kw['target_start_date']) object.setStartDate(kw['target_start_date'])
object.setStopDate(kw['target_stop_date']) object.setStopDate(kw['target_stop_date'])
# Find the organisation and the person folder # Find the organisation and the person folder
...@@ -379,7 +379,7 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -379,7 +379,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
previous_owner_type = 'o' # Organisation is more important than the person previous_owner_type = 'o' # Organisation is more important than the person
# This is a particular case where the user put # This is a particular case where the user put
# the name of an organisation in his own name # the name of an organisation in his own name
if not kw.has_key('organisation'): if 'organisation' not in kw:
kw['organisation'] = org_object.getId() kw['organisation'] = org_object.getId()
#if len(previous_owner_type) == 0: #if len(previous_owner_type) == 0:
# previous_owner_type = None # previous_owner_type = None
...@@ -387,11 +387,11 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -387,11 +387,11 @@ class ERP5ShopOrderConduit(ERP5Conduit):
# Try to know the type of the current storever customer # Try to know the type of the current storever customer
owner_type = '' owner_type = ''
if kw.has_key('name') and kw['name'] not in (None, ''): if 'name' in kw and kw['name'] not in (None, ''):
owner_type += 'p' owner_type += 'p'
if kw.has_key('organisation') and kw['organisation'] not in (None, '', 'none'): if 'organisation' in kw and kw['organisation'] not in (None, '', 'none'):
owner_type += 'o' owner_type += 'o'
if kw.has_key('eu_vat') and kw['eu_vat'] not in (None, '') and owner_type.find('o') == -1: if 'eu_vat' in kw and kw['eu_vat'] not in (None, '') and owner_type.find('o') == -1:
owner_type += 'o' owner_type += 'o'
if len(owner_type) == 0: if len(owner_type) == 0:
owner_type = None owner_type = None
...@@ -511,11 +511,11 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -511,11 +511,11 @@ class ERP5ShopOrderConduit(ERP5Conduit):
# elif previous_address.strip().lower() != kw['address'].strip().lower(): # elif previous_address.strip().lower() != kw['address'].strip().lower():
# LOG('We have to make the fusion of previous address with the current one >>>>>>>', 0, '') # LOG('We have to make the fusion of previous address with the current one >>>>>>>', 0, '')
if kw.has_key('city') and kw['city']!=None: if 'city' in kw and kw['city']!=None:
person_object.setDefaultAddressCity(kw['city'].title()) person_object.setDefaultAddressCity(kw['city'].title())
if kw.has_key('address') and kw['address'] != None: if 'address' in kw and kw['address'] != None:
person_object.setDefaultAddressStreetAddress(kw['address'].title()) person_object.setDefaultAddressStreetAddress(kw['address'].title())
if kw.has_key('zipcode') and kw['zipcode']!=None: if 'zipcode' in kw and kw['zipcode']!=None:
person_object.setDefaultAddressZipCode(kw['zipcode']) person_object.setDefaultAddressZipCode(kw['zipcode'])
# # TODO : set the person products interest (storever, etc) # # TODO : set the person products interest (storever, etc)
# Search the country in the region category # Search the country in the region category
...@@ -525,15 +525,15 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -525,15 +525,15 @@ class ERP5ShopOrderConduit(ERP5Conduit):
person_object.setDefaultAddressRegion(region_path) person_object.setDefaultAddressRegion(region_path)
# else: # else:
# # TODO : Ask the user to select an appropriate region # # TODO : Ask the user to select an appropriate region
if kw.has_key('email') and kw['email'] != None: if 'email' in kw and kw['email'] != None:
person_object.setDefaultEmailText(kw['email']) person_object.setDefaultEmailText(kw['email'])
if kw.has_key('phone') and kw['phone'] != None: if 'phone' in kw and kw['phone'] != None:
person_object.setDefaultTelephoneText(kw['phone']) person_object.setDefaultTelephoneText(kw['phone'])
# # TODO : Don't work # # TODO : Don't work
# person_object.setDefaultCareerRole("client") # person_object.setDefaultCareerRole("client")
# Split the name to give at least a required LastName # Split the name to give at least a required LastName
# Then the title will be automaticaly created by the Person object from this data # Then the title will be automaticaly created by the Person object from this data
if kw.has_key('name') and kw['name'] != None: if 'name' in kw and kw['name'] != None:
splitted_name = kw['name'].strip().split(" ") splitted_name = kw['name'].strip().split(" ")
person_object.setLastName((splitted_name[-1]).title()) person_object.setLastName((splitted_name[-1]).title())
if len(splitted_name) > 1: if len(splitted_name) > 1:
...@@ -545,13 +545,13 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -545,13 +545,13 @@ class ERP5ShopOrderConduit(ERP5Conduit):
if owner_type.find('o') != -1 and previous_owner_type =='o': if owner_type.find('o') != -1 and previous_owner_type =='o':
# # TODO : fix this # # TODO : fix this
# person_object.setSubordination("organisation/" + owner_id) # person_object.setSubordination("organisation/" + owner_id)
if kw.has_key('organisation') and kw['organisation'] != None: if 'organisation' in kw and kw['organisation'] != None:
org_object.setTitle(kw['organisation'].title()) org_object.setTitle(kw['organisation'].title())
org_object.setCorporateName(kw['organisation'].title()) org_object.setCorporateName(kw['organisation'].title())
if kw.has_key('eu_vat') and kw['eu_vat'] != None: if 'eu_vat' in kw and kw['eu_vat'] != None:
org_object.setVatCode(kw['eu_vat']) org_object.setVatCode(kw['eu_vat'])
# Test for debug # Test for debug
if (not (kw.has_key('organisation')) or (kw.has_key('organisation') and kw['organisation'] != None)) and (not (kw.has_key('eu_vat')) or (kw.has_key('eu_vat') and kw['eu_vat'] != None)): if (not ('organisation' in kw) or ('organisation' in kw and kw['organisation'] != None)) and (not ('eu_vat' in kw) or ('eu_vat' in kw and kw['eu_vat'] != None)):
LOG("AARRGG ! Big conflict detected : this organisation has no title or eu_vat. These properties are primary key to deduced that the storever member account was an organisation >>>>>>>>>>", 0, '') LOG("AARRGG ! Big conflict detected : this organisation has no title or eu_vat. These properties are primary key to deduced that the storever member account was an organisation >>>>>>>>>>", 0, '')
org_object.setRole("client") org_object.setRole("client")
...@@ -570,17 +570,17 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -570,17 +570,17 @@ class ERP5ShopOrderConduit(ERP5Conduit):
object.setDestination("organisation/" + owner_id) object.setDestination("organisation/" + owner_id)
object.setDestinationSection("organisation/" + owner_id) object.setDestinationSection("organisation/" + owner_id)
# All information describe the organisation # All information describe the organisation
if kw.has_key('organisation') and kw['organisation'] != None: if 'organisation' in kw and kw['organisation'] != None:
org_object.setTitle(kw['organisation'].title()) org_object.setTitle(kw['organisation'].title())
org_object.setCorporateName(kw['organisation'].title()) org_object.setCorporateName(kw['organisation'].title())
org_object.setRole("client") org_object.setRole("client")
if kw.has_key('eu_vat') and kw['eu_vat'] != None: if 'eu_vat' in kw and kw['eu_vat'] != None:
org_object.setVatCode(kw['eu_vat']) org_object.setVatCode(kw['eu_vat'])
if kw.has_key('address') and kw['address'] != None: if 'address' in kw and kw['address'] != None:
org_object.setDefaultAddressStreetAddress(kw['address'].title()) org_object.setDefaultAddressStreetAddress(kw['address'].title())
if kw.has_key('city') and kw['city'] != None: if 'city' in kw and kw['city'] != None:
org_object.setDefaultAddressCity(kw['city'].title()) org_object.setDefaultAddressCity(kw['city'].title())
if kw.has_key('zipcode') and kw['zipcode'] != None: if 'zipcode' in kw and kw['zipcode'] != None:
org_object.setDefaultAddressZipCode(kw['zipcode']) org_object.setDefaultAddressZipCode(kw['zipcode'])
# Search the country in the region category # Search the country in the region category
if kw['country'] != None: if kw['country'] != None:
...@@ -589,13 +589,13 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -589,13 +589,13 @@ class ERP5ShopOrderConduit(ERP5Conduit):
org_object.setDefaultAddressRegion(region_path) org_object.setDefaultAddressRegion(region_path)
# else: # else:
# # TODO : Ask the user to select an appropriate region # # TODO : Ask the user to select an appropriate region
if kw.has_key('email') and kw['email'] != None: if 'email' in kw and kw['email'] != None:
org_object.setDefaultEmailText(kw['email']) org_object.setDefaultEmailText(kw['email'])
if kw.has_key('phone') and kw['phone'] != None: if 'phone' in kw and kw['phone'] != None:
org_object.setDefaultTelephoneText(kw['phone']) org_object.setDefaultTelephoneText(kw['phone'])
# Save the billing address in the description, because there is no dedicated place for it # Save the billing address in the description, because there is no dedicated place for it
if kw.has_key('billing_address') and len(kw['billing_address']) > 0: if 'billing_address' in kw and len(kw['billing_address']) > 0:
object.setDescription("Send the bill to : " + kw['billing_address']) object.setDescription("Send the bill to : " + kw['billing_address'])
# Set the Title because its required # Set the Title because its required
object.setTitle("Storever Order " + str(kw['order_id'])) object.setTitle("Storever Order " + str(kw['order_id']))
......
...@@ -111,11 +111,11 @@ class WebServiceRequest(XMLObject, ZopePageTemplate): ...@@ -111,11 +111,11 @@ class WebServiceRequest(XMLObject, ZopePageTemplate):
if REQUEST is not None: if REQUEST is not None:
return self.view() return self.view()
#LOG("_call__", 300, kw) #LOG("_call__", 300, kw)
if kw.has_key("id"): if "id" in kw:
kw[self.getIDParameterName()] = str(kw.pop("id")) kw[self.getIDParameterName()] = str(kw.pop("id"))
sub_id = None sub_id = None
if kw.has_key(self.getIDParameterName()) and ID_SEPARATOR in kw[self.getIDParameterName()]: if self.getIDParameterName() in kw and ID_SEPARATOR in kw[self.getIDParameterName()]:
kw[self.getIDParameterName()], sub_id = kw[self.getIDParameterName()].split(ID_SEPARATOR) kw[self.getIDParameterName()], sub_id = kw[self.getIDParameterName()].split(ID_SEPARATOR)
object_list = [] object_list = []
......
...@@ -68,7 +68,7 @@ class NewEchoDictTarget: ...@@ -68,7 +68,7 @@ class NewEchoDictTarget:
self.current_parser = subtag self.current_parser = subtag
else: else:
if self._current_object is not None and \ if self._current_object is not None and \
not self._current_object.has_key(value): value not in self._current_object:
# Create default value # Create default value
self._current_object[value] = "" self._current_object[value] = ""
self._current_key = value self._current_key = value
...@@ -102,7 +102,7 @@ class NewEchoDictTarget: ...@@ -102,7 +102,7 @@ class NewEchoDictTarget:
def data(self, data): def data(self, data):
if self._current_key and len(data.strip()): if self._current_key and len(data.strip()):
# for the element browsed several time # for the element browsed several time
if self._current_object.has_key(self._current_key): if self._current_key in self._current_object:
data = self._current_object[self._current_key] + data data = self._current_object[self._current_key] + data
self._current_object[self._current_key] = data self._current_object[self._current_key] = data
...@@ -148,7 +148,7 @@ class EchoDictTarget: ...@@ -148,7 +148,7 @@ class EchoDictTarget:
if root: if root:
self._current_object = {} self._current_object = {}
if self._current_object is not None and \ if self._current_object is not None and \
not self._current_object.has_key(value): value not in self._current_object:
self._current_object[value] = "" self._current_object[value] = ""
self._current_key = value self._current_key = value
else: else:
...@@ -171,7 +171,7 @@ class EchoDictTarget: ...@@ -171,7 +171,7 @@ class EchoDictTarget:
def data(self, data): def data(self, data):
if self._current_key and len(data.strip()): if self._current_key and len(data.strip()):
# for the element browsed several time # for the element browsed several time
if self._current_object.has_key(self._current_key): if self._current_key in self._current_object:
data = self._current_object[self._current_key] + data data = self._current_object[self._current_key] + data
self._current_object[self._current_key] = data self._current_object[self._current_key] = data
......
...@@ -25,7 +25,7 @@ def createCategory(object_mapping=None, category=""): ...@@ -25,7 +25,7 @@ def createCategory(object_mapping=None, category=""):
mapping_dict = {} mapping_dict = {}
destination_list = [] destination_list = []
for line in listbox: for line in listbox:
if line.has_key('listbox_key'): if 'listbox_key' in line:
line_id = line['listbox_key'] line_id = line['listbox_key']
mapping_dict[line_id] = line mapping_dict[line_id] = line
if line["destination_reference_text"] != "": if line["destination_reference_text"] != "":
......
...@@ -14,14 +14,14 @@ def getMappingChildUid(mapping): ...@@ -14,14 +14,14 @@ def getMappingChildUid(mapping):
def resetListBox(listbox, uid_list): def resetListBox(listbox, uid_list):
for line in listbox: for line in listbox:
if line.has_key('listbox_key'): if 'listbox_key' in line:
line_id = line['listbox_key'] line_id = line['listbox_key']
if line_id in uid_list: if line_id in uid_list:
line['destination_reference'] = "" line['destination_reference'] = ""
return listbox return listbox
for line in listbox: for line in listbox:
if line.has_key('listbox_key'): if 'listbox_key' in line:
line_id = line['listbox_key'] line_id = line['listbox_key']
mapping_dict[line_id] = line mapping_dict[line_id] = line
if line["destination_reference_text"] != "": if line["destination_reference_text"] != "":
......
...@@ -73,11 +73,11 @@ if len(client_dict): ...@@ -73,11 +73,11 @@ if len(client_dict):
line_total_amount = 0 line_total_amount = 0
for period in period_list: for period in period_list:
# client -> period # client -> period
if client_dict[client_title].has_key(period): if period in client_dict[client_title]:
obj['Amount %s' %(period)] = round(client_dict[client_title][period]['amount'], 2) obj['Amount %s' %(period)] = round(client_dict[client_title][period]['amount'], 2)
line_total_amount += client_dict[client_title][period]['amount'] line_total_amount += client_dict[client_title][period]['amount']
if report_group_by == "client": if report_group_by == "client":
if period_counter_dict.has_key('Amount %s' %(period)): if 'Amount %s' %(period) in period_counter_dict:
period_counter_dict['Amount %s' %(period)] = period_counter_dict['Amount %s' %(period)] + client_dict[client_title][period]['amount'] period_counter_dict['Amount %s' %(period)] = period_counter_dict['Amount %s' %(period)] + client_dict[client_title][period]['amount']
else: else:
period_counter_dict['Amount %s' %(period)] = client_dict[client_title][period]['amount'] period_counter_dict['Amount %s' %(period)] = client_dict[client_title][period]['amount']
...@@ -85,7 +85,7 @@ if len(client_dict): ...@@ -85,7 +85,7 @@ if len(client_dict):
obj['Amount %s' %(period)] = 0 obj['Amount %s' %(period)] = 0
obj['total amount'] = round(line_total_amount, 2) obj['total amount'] = round(line_total_amount, 2)
if report_group_by == "client": if report_group_by == "client":
if period_counter_dict.has_key('total amount'): if 'total amount' in period_counter_dict:
period_counter_dict['total amount'] = period_counter_dict['total amount'] + line_total_amount period_counter_dict['total amount'] = period_counter_dict['total amount'] + line_total_amount
else: else:
period_counter_dict['total amount'] = line_total_amount period_counter_dict['total amount'] = line_total_amount
...@@ -94,7 +94,7 @@ if len(client_dict): ...@@ -94,7 +94,7 @@ if len(client_dict):
if report_group_by == "both": if report_group_by == "both":
product_lines_list = [] product_lines_list = []
# one line per product # one line per product
if product_dict.has_key(client_title): if client_title in product_dict:
line_product_dict = product_dict[client_title] line_product_dict = product_dict[client_title]
for product_title in line_product_dict.keys(): for product_title in line_product_dict.keys():
obj = Object(uid="new_") obj = Object(uid="new_")
...@@ -102,7 +102,7 @@ if len(client_dict): ...@@ -102,7 +102,7 @@ if len(client_dict):
line_total_amount = 0 line_total_amount = 0
line_total_quantity = 0 line_total_quantity = 0
for period in period_list: for period in period_list:
if line_product_dict[product_title].has_key(period): if period in line_product_dict[product_title]:
obj['Amount %s' %(period)] = round(line_product_dict[product_title][period]['amount'], 2) obj['Amount %s' %(period)] = round(line_product_dict[product_title][period]['amount'], 2)
obj['Quantity %s' %(period)] = line_product_dict[product_title][period]['quantity'] obj['Quantity %s' %(period)] = line_product_dict[product_title][period]['quantity']
obj['Quantity Unit %s' %(period)] = line_product_dict[product_title][period]['quantity_unit'] obj['Quantity Unit %s' %(period)] = line_product_dict[product_title][period]['quantity_unit']
...@@ -110,7 +110,7 @@ if len(client_dict): ...@@ -110,7 +110,7 @@ if len(client_dict):
line_total_amount += line_product_dict[product_title][period]['amount'] line_total_amount += line_product_dict[product_title][period]['amount']
line_total_quantity += line_product_dict[product_title][period]['quantity'] line_total_quantity += line_product_dict[product_title][period]['quantity']
# counter for stat line # counter for stat line
if period_counter_dict.has_key('Amount %s' %(period)): if 'Amount %s' %(period) in period_counter_dict:
period_counter_dict['Amount %s' %(period)] = period_counter_dict['Amount %s' %(period)] + \ period_counter_dict['Amount %s' %(period)] = period_counter_dict['Amount %s' %(period)] + \
line_product_dict[product_title][period]['amount'] line_product_dict[product_title][period]['amount']
else: else:
...@@ -124,7 +124,7 @@ if len(client_dict): ...@@ -124,7 +124,7 @@ if len(client_dict):
obj['total quantity'] = line_total_quantity obj['total quantity'] = line_total_quantity
obj['total amount'] = round(line_total_amount, 2) obj['total amount'] = round(line_total_amount, 2)
# total for stat line # total for stat line
if period_counter_dict.has_key('total amount'): if 'total amount' in period_counter_dict:
period_counter_dict['total amount'] = period_counter_dict['total amount'] + line_total_amount period_counter_dict['total amount'] = period_counter_dict['total amount'] + line_total_amount
else: else:
period_counter_dict['total amount'] = line_total_amount period_counter_dict['total amount'] = line_total_amount
...@@ -142,7 +142,7 @@ else: ...@@ -142,7 +142,7 @@ else:
line_total_amount = 0 line_total_amount = 0
line_total_quantity = 0 line_total_quantity = 0
for period in period_list: for period in period_list:
if product_dict[product_title].has_key(period): if period in product_dict[product_title]:
obj['Amount %s' %(period)] = round(product_dict[product_title][period]['amount'],2) obj['Amount %s' %(period)] = round(product_dict[product_title][period]['amount'],2)
obj['Quantity %s' %(period)] = product_dict[product_title][period]['quantity'] obj['Quantity %s' %(period)] = product_dict[product_title][period]['quantity']
obj['Quantity Unit %s' %(period)] = product_dict[product_title][period]['quantity_unit'] obj['Quantity Unit %s' %(period)] = product_dict[product_title][period]['quantity_unit']
...@@ -150,7 +150,7 @@ else: ...@@ -150,7 +150,7 @@ else:
line_total_amount += product_dict[product_title][period]['amount'] line_total_amount += product_dict[product_title][period]['amount']
line_total_quantity += product_dict[product_title][period]['quantity'] line_total_quantity += product_dict[product_title][period]['quantity']
# counter for stat line # counter for stat line
if period_counter_dict.has_key('Amount %s' %(period)): if 'Amount %s' %(period) in period_counter_dict:
period_counter_dict['Amount %s' %(period)] = period_counter_dict['Amount %s' %(period)] + product_dict[product_title][period]['amount'] period_counter_dict['Amount %s' %(period)] = period_counter_dict['Amount %s' %(period)] + product_dict[product_title][period]['amount']
else: else:
period_counter_dict['Amount %s' %(period)] = product_dict[product_title][period]['amount'] period_counter_dict['Amount %s' %(period)] = product_dict[product_title][period]['amount']
...@@ -162,7 +162,7 @@ else: ...@@ -162,7 +162,7 @@ else:
obj['total quantity'] = line_total_quantity obj['total quantity'] = line_total_quantity
obj['total amount'] = round(line_total_amount,2) obj['total amount'] = round(line_total_amount,2)
# total for stat line # total for stat line
if period_counter_dict.has_key('total amount'): if 'total amount' in period_counter_dict:
period_counter_dict['total amount'] = period_counter_dict['total amount'] + line_total_amount period_counter_dict['total amount'] = period_counter_dict['total amount'] + line_total_amount
else: else:
period_counter_dict['total amount'] = line_total_amount period_counter_dict['total amount'] = line_total_amount
......
...@@ -35,13 +35,13 @@ for result in document_list: ...@@ -35,13 +35,13 @@ for result in document_list:
else: else:
client_title = result['source_section_title'] client_title = result['source_section_title']
# FIXME: if two clients have the same title, do we want to group ? # FIXME: if two clients have the same title, do we want to group ?
if not client_dict.has_key(client_title): if client_title not in client_dict:
client_dict[client_title] = {} client_dict[client_title] = {}
if client_dict[client_title].has_key(period): if period in client_dict[client_title]:
client_dict[client_title][period]['amount'] = client_dict[client_title][period]['amount'] + (total_price or 0) client_dict[client_title][period]['amount'] = client_dict[client_title][period]['amount'] + (total_price or 0)
else: else:
client_dict[client_title][period] = {'amount' : total_price or 0} client_dict[client_title][period] = {'amount' : total_price or 0}
if not product_dict.has_key(client_title): if client_title not in product_dict:
line_dict = product_dict[client_title] = {} line_dict = product_dict[client_title] = {}
else: else:
line_dict = product_dict[client_title] line_dict = product_dict[client_title]
...@@ -54,12 +54,12 @@ for result in document_list: ...@@ -54,12 +54,12 @@ for result in document_list:
for line in line_list: for line in line_list:
# FIXME: if two resources have the same title, do we want to group ? # FIXME: if two resources have the same title, do we want to group ?
product_title = line.resource_title product_title = line.resource_title
if not line_dict.has_key(product_title): if product_title not in line_dict:
line_dict[product_title] = {period :{"amount" : line.total_price or 0, line_dict[product_title] = {period :{"amount" : line.total_price or 0,
"quantity" : line.quantity or 0, "quantity" : line.quantity or 0,
"quantity_unit" : translate(line.strict_quantity_unit_title)}} "quantity_unit" : translate(line.strict_quantity_unit_title)}}
else: else:
if not line_dict[product_title].has_key(period): if period not in line_dict[product_title]:
line_dict[product_title][period] = {"amount" : line.total_price or 0, line_dict[product_title][period] = {"amount" : line.total_price or 0,
"quantity" : line.quantity or 0, "quantity" : line.quantity or 0,
"quantity_unit" : translate(line.strict_quantity_unit_title)} "quantity_unit" : translate(line.strict_quantity_unit_title)}
......
...@@ -78,7 +78,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -78,7 +78,7 @@ class TestTradeReports(ERP5ReportTestCase):
('demo_site_A', 'DEMO-SITE-A'), ('demo_site_A', 'DEMO-SITE-A'),
('demo_site_B', 'DEMO-SITE-B'), ('demo_site_B', 'DEMO-SITE-B'),
): ):
if not self.portal_categories['site'].has_key(site_id): if site_id not in self.portal_categories['site']:
self.portal_categories.site.newContent( self.portal_categories.site.newContent(
portal_type='Category', portal_type='Category',
title=site_id, title=site_id,
...@@ -87,7 +87,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -87,7 +87,7 @@ class TestTradeReports(ERP5ReportTestCase):
id=site_id) id=site_id)
# Colour categories # Colour categories
for colour_id in ('colour1', 'colour2',): for colour_id in ('colour1', 'colour2',):
if not self.portal_categories['colour'].has_key(colour_id): if colour_id not in self.portal_categories['colour']:
self.portal_categories.colour.newContent( self.portal_categories.colour.newContent(
portal_type='Category', portal_type='Category',
title=colour_id, title=colour_id,
...@@ -96,7 +96,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -96,7 +96,7 @@ class TestTradeReports(ERP5ReportTestCase):
# create group categories # create group categories
for group_id in ('g1', 'g2', 'g3'): for group_id in ('g1', 'g2', 'g3'):
if not self.portal_categories['group'].has_key(group_id): if group_id not in self.portal_categories['group']:
self.portal_categories.group.newContent( self.portal_categories.group.newContent(
portal_type='Category', portal_type='Category',
title=group_id, title=group_id,
...@@ -105,7 +105,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -105,7 +105,7 @@ class TestTradeReports(ERP5ReportTestCase):
# create use categories # create use categories
for use_id in ('u1', 'u2'): for use_id in ('u1', 'u2'):
if not self.portal_categories['use'].has_key(use_id): if use_id not in self.portal_categories['use']:
self.portal_categories.use.newContent( self.portal_categories.use.newContent(
portal_type='Category', portal_type='Category',
title=use_id, title=use_id,
...@@ -113,7 +113,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -113,7 +113,7 @@ class TestTradeReports(ERP5ReportTestCase):
id=use_id) id=use_id)
# currencies # currencies
if not self.portal.currency_module.has_key('EUR'): if 'EUR' not in self.portal.currency_module:
self.portal.currency_module.newContent( self.portal.currency_module.newContent(
portal_type='Currency', portal_type='Currency',
id='EUR', id='EUR',
...@@ -122,7 +122,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -122,7 +122,7 @@ class TestTradeReports(ERP5ReportTestCase):
# product line # product line
for product_line in ('product_line_a','product_line_b'): for product_line in ('product_line_a','product_line_b'):
if not self.portal_categories.product_line.has_key(product_line): if product_line not in self.portal_categories.product_line:
self.portal_categories.product_line.newContent( self.portal_categories.product_line.newContent(
portal_type='Category', portal_type='Category',
title=product_line, title=product_line,
...@@ -131,7 +131,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -131,7 +131,7 @@ class TestTradeReports(ERP5ReportTestCase):
) )
# create organisations (with no organisation member of g3) # create organisations (with no organisation member of g3)
if not self.organisation_module.has_key('Organisation_1'): if 'Organisation_1' not in self.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='Organisation_1', reference='Organisation_1',
...@@ -145,7 +145,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -145,7 +145,7 @@ class TestTradeReports(ERP5ReportTestCase):
default_address_street_address='1 Organisation Street', default_address_street_address='1 Organisation Street',
default_address_zip_code='111', default_address_zip_code='111',
default_address_city='City', ) default_address_city='City', )
if not self.organisation_module.has_key('Organisation_2'): if 'Organisation_2' not in self.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='Organisation_2', reference='Organisation_2',
...@@ -154,7 +154,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -154,7 +154,7 @@ class TestTradeReports(ERP5ReportTestCase):
group='g2', group='g2',
site='demo_site_B') site='demo_site_B')
# no group no site # no group no site
if not self.organisation_module.has_key('Organisation_3'): if 'Organisation_3' not in self.organisation_module:
self.portal.organisation_module.newContent( self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
reference='Organisation_3', reference='Organisation_3',
...@@ -162,12 +162,12 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -162,12 +162,12 @@ class TestTradeReports(ERP5ReportTestCase):
id='Organisation_3',) id='Organisation_3',)
# create unit categories # create unit categories
if not self.portal_categories.quantity_unit.has_key('mass'): if 'mass' not in self.portal_categories.quantity_unit:
self.portal_categories.quantity_unit.newContent( self.portal_categories.quantity_unit.newContent(
portal_type='Category', portal_type='Category',
id='mass') id='mass')
for unit_id in ('kg', 'g',): for unit_id in ('kg', 'g',):
if not self.portal_categories.quantity_unit.mass.has_key(unit_id): if unit_id not in self.portal_categories.quantity_unit.mass:
self.portal_categories.quantity_unit.mass.newContent( self.portal_categories.quantity_unit.mass.newContent(
portal_type='Category', portal_type='Category',
title=unit_id.title(), title=unit_id.title(),
...@@ -175,7 +175,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -175,7 +175,7 @@ class TestTradeReports(ERP5ReportTestCase):
id=unit_id) id=unit_id)
# and corresponding unit conversion group # and corresponding unit conversion group
if not self.portal.quantity_unit_conversion_module.has_key('mass_conversion_group'): if 'mass_conversion_group' not in self.portal.quantity_unit_conversion_module:
self.portal.quantity_unit_conversion_module.newContent( self.portal.quantity_unit_conversion_module.newContent(
portal_type='Quantity Unit Conversion Group', portal_type='Quantity Unit Conversion Group',
id='mass_conversion_group', id='mass_conversion_group',
...@@ -216,7 +216,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -216,7 +216,7 @@ class TestTradeReports(ERP5ReportTestCase):
variation_base_category_list=['colour'], variation_base_category_list=['colour'],
colour_list=['colour1', 'colour2'], colour_list=['colour1', 'colour2'],
) )
if not self.portal.service_module.has_key('service_a'): if 'service_a' not in self.portal.service_module:
self.portal.service_module.newContent( self.portal.service_module.newContent(
portal_type='Service', portal_type='Service',
id='service_a', id='service_a',
......
...@@ -8,7 +8,7 @@ if session_id is None or not session_id.startswith("erp5zuite"): ...@@ -8,7 +8,7 @@ if session_id is None or not session_id.startswith("erp5zuite"):
request.RESPONSE.setCookie('erp5_session_id', session_id, expires=(now +expire_timeout_days).fCommon(), path='/') request.RESPONSE.setCookie('erp5_session_id', session_id, expires=(now +expire_timeout_days).fCommon(), path='/')
session = context.portal_sessions[session_id] session = context.portal_sessions[session_id]
if not session.has_key('tempfolder') or session['tempfolder'] == '': if 'tempfolder' not in session or session['tempfolder'] == '':
session['tempfolder'] = context.Zuite_createTempFolder() + '/' session['tempfolder'] = context.Zuite_createTempFolder() + '/'
return session['tempfolder'] + str(context.portal_ids.generateNewId(id_generator='zuite', id_group=context.getId(), default=1)) + '.png' return session['tempfolder'] + str(context.portal_ids.generateNewId(id_generator='zuite', id_group=context.getId(), default=1)) + '.png'
...@@ -4,11 +4,11 @@ if web_page_context: ...@@ -4,11 +4,11 @@ if web_page_context:
no_web_page = False no_web_page = False
form_id = 'view' form_id = 'view'
else: else:
no_web_page = not request.has_key('web_page') or request['web_page'] is None or not request['web_page'] no_web_page = 'web_page' not in request or request['web_page'] is None or not request['web_page']
form_id = 'Zuite_viewRunZeleniumTestDialog' form_id = 'Zuite_viewRunZeleniumTestDialog'
no_reference = not request.has_key('web_page_reference') or request['web_page_reference'] is None or not request['web_page_reference'] no_reference = 'web_page_reference' not in request or request['web_page_reference'] is None or not request['web_page_reference']
no_url = not request.has_key('url') or request['url'] is None or not request['url'] no_url = 'url' not in request or request['url'] is None or not request['url']
if no_web_page and no_url and no_reference: if no_web_page and no_url and no_reference:
if validator: if validator:
......
...@@ -171,7 +171,7 @@ class WebSite(WebSection): ...@@ -171,7 +171,7 @@ class WebSite(WebSection):
path = section.getPhysicalPath() path = section.getPhysicalPath()
for i in range(0, len(path)): for i in range(0, len(path)):
sub_path = tuple(path[0:i]) sub_path = tuple(path[0:i])
if section_dict.has_key(sub_path): if sub_path in section_dict:
del section_dict[sub_path] del section_dict[sub_path]
section_list = section_dict.values() section_list = section_dict.values()
......
...@@ -12,7 +12,7 @@ if username is not None: ...@@ -12,7 +12,7 @@ if username is not None:
) )
) )
REQUEST = portal.REQUEST REQUEST = portal.REQUEST
if REQUEST.has_key('portal_skin'): if 'portal_skin' in REQUEST:
portal.portal_skins.clearSkinCookie() portal.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/') REQUEST.RESPONSE.expireCookie('__ac', path='/')
......
...@@ -12,7 +12,7 @@ if username is not None: ...@@ -12,7 +12,7 @@ if username is not None:
) )
) )
REQUEST = portal.REQUEST REQUEST = portal.REQUEST
if REQUEST.has_key('portal_skin'): if 'portal_skin' in REQUEST:
portal.portal_skins.clearSkinCookie() portal.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/') REQUEST.RESPONSE.expireCookie('__ac', path='/')
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
portal = context.getPortalObject() portal = context.getPortalObject()
# Clean up the contents. # Clean up the contents.
if portal.web_site_module.has_key('test_web_site'): if 'test_web_site' in portal.web_site_module:
portal.web_site_module.manage_delObjects('test_web_site') portal.web_site_module.manage_delObjects('test_web_site')
if portal.web_site_module.has_key('web_site_test'): if 'web_site_test' in portal.web_site_module:
portal.web_site_module.manage_delObjects('web_site_test') portal.web_site_module.manage_delObjects('web_site_test')
if portal.web_site_module.has_key('test_web_site_2'): if 'test_web_site_2' in portal.web_site_module:
portal.web_site_module.manage_delObjects('test_web_site_2') portal.web_site_module.manage_delObjects('test_web_site_2')
if portal.web_site_module.has_key('test_web_site'): if 'test_web_site' in portal.web_site_module:
portal.web_site_module.manage_delObjects('test_web_site') portal.web_site_module.manage_delObjects('test_web_site')
if portal.person_module.has_key('test_website_predicate'): if 'test_website_predicate' in portal.person_module:
portal.person_module.manage_delObjects('test_website_predicate') portal.person_module.manage_delObjects('test_website_predicate')
portal.web_page_module.manage_delObjects( portal.web_page_module.manage_delObjects(
...@@ -22,7 +22,7 @@ portal.web_page_module.manage_delObjects( ...@@ -22,7 +22,7 @@ portal.web_page_module.manage_delObjects(
if x.getTitle().startswith('test_')]) if x.getTitle().startswith('test_')])
# Create new users # Create new users
if not portal.person_module.has_key('test_webmaster'): if 'test_webmaster' not in portal.person_module:
person = portal.person_module.newContent(id='test_webmaster', portal_type='Person') person = portal.person_module.newContent(id='test_webmaster', portal_type='Person')
else: else:
person = portal.person_module.test_webmaster person = portal.person_module.test_webmaster
...@@ -47,6 +47,6 @@ if person.getValidationState() != 'validated': ...@@ -47,6 +47,6 @@ if person.getValidationState() != 'validated':
person.validate() person.validate()
# Create region category # Create region category
if not portal.portal_categories.region.has_key('test_web_region'): if 'test_web_region' not in portal.portal_categories.region:
portal.portal_categories.region.newContent(id='test_web_region', portal_type='Category', title='test_web_region') portal.portal_categories.region.newContent(id='test_web_region', portal_type='Category', title='test_web_region')
return 'Reset Successfully.' return 'Reset Successfully.'
...@@ -81,6 +81,8 @@ class Python3StyleTest(ERP5TypeTestCase): ...@@ -81,6 +81,8 @@ class Python3StyleTest(ERP5TypeTestCase):
def test_importFixApplied(self): def test_importFixApplied(self):
self._testFixer('import') self._testFixer('import')
def test_hasKeyFixApplied(self):
self._testFixer('has_key')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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