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

py2/py3: stop using deprecated has_key().

parent 21ece045
......@@ -6,7 +6,7 @@
website = context.getWebSiteValue()
REQUEST = context.REQUEST
if REQUEST.has_key('portal_skin'):
if 'portal_skin' in REQUEST:
context.portal_skins.clearSkinCookie()
#XXX get cookie name from key authentication plugin
......
......@@ -20,7 +20,7 @@ def getSubFieldDict():
item_key = '/'.join(item_split[:split_depth])
# 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)
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key
......@@ -57,7 +57,7 @@ for item_value in value_list:
item_split = item_value.split('/')
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
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key
......
......@@ -142,7 +142,7 @@ else:
reference_dict = getattr(context, property_override_method_id)(instance=actual_object)
do_reindex = False
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)
else:
reference_value = reference_dict[attribute_id]
......
......@@ -29,7 +29,7 @@ if form_id is not None:
# Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields():
field_id = f.id
if request.has_key(field_id):
if field_id in request:
value = request.get(field_id)
if callable(value):
value(request)
......
......@@ -3,7 +3,7 @@
"""
website = context.getWebSiteValue()
REQUEST = context.REQUEST
if REQUEST.has_key('portal_skin'):
if 'portal_skin' in REQUEST:
context.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/')
REQUEST.RESPONSE.expireCookie('__ac_facebook_hash', path='/')
......
......@@ -10,7 +10,7 @@ for item in item_list:
item_key = '/'.join(item_split[:split_depth])
base_category = item_split[0]
# 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)
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key
......
......@@ -86,7 +86,7 @@ try:
bath = ''
for item in created_item_list:
bath = str(item.grouping_reference)
if bath_dict.has_key(bath):
if bath in bath_dict:
bath_dict[str(bath)].extend([item])
else:
bath_dict[str(bath)] = [item]
......@@ -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)
movement_list.append(new_movement[0].getRelativeUrl())
# update root movement if require
if bath_dict.has_key(movement_bath):
if movement_bath in bath_dict:
items = bath_dict[movement_bath]
quantity = 0
for item in items:
......@@ -181,7 +181,7 @@ try:
if cell.getVariationText() == variation_text:
# update aggregate list with items
cell_aggregate_list = cell.getAggregateValueList()
if bath_dict.has_key(line_bath):
if line_bath in bath_dict:
# new items on cell
cell_item = bath_dict[line_bath]
cell_aggregate_list.extend(cell_item)
......
......@@ -159,10 +159,10 @@ class TestApparelModel(ERP5TypeTestCase):
self.assertEqual(elasthane.getProperty('quantity'), 0.12)
# 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]
self.assertTrue(index.has_key('composition/elasthane'))
self.assertTrue(index.has_key('composition/acrylique'))
self.assertTrue('composition/elasthane' in index)
self.assertTrue('composition/acrylique' in index)
def test_checkCopyColourRangeVariation(self):
'''
......
......@@ -26,7 +26,7 @@ node_inventory_dict = {}
activate_kw = {"tag": tag}
for inventory in node_inventory_list:
# 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",
destination=inventory.node_relative_url,
......@@ -99,7 +99,7 @@ for inv in node_inventory_dict.values():
payment_inventory_dict = {}
for inventory in payment_inventory_list:
# 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",
destination=inventory.node_relative_url,
......
......@@ -96,7 +96,7 @@ class MovementGroup(XMLObject):
# XXX it can be wrong. we need a good way to get hash value, or
# we should compare for all pairs.
key = repr(property_dict)
if tmp_dict.has_key(key):
if key in tmp_dict:
tmp_dict[key][0].append(movement)
else:
tmp_dict[key] = [[movement], property_dict]
......
......@@ -254,7 +254,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
delta = inventory_item.inventory - min_stock
node_uid = inventory_item.node_uid
# 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']
optimized_kw = {}
if kw.get('group_by_variation', 1):
......
......@@ -58,7 +58,7 @@ result_list = context.portal_catalog.countResults(select_dict={'date': 'DATE_FOR
# build result dict per portal_type then period
portal_type_count_dict = {}
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]
else:
portal_type_count_dict[result[2]] = {result[1]:result[0]}
......@@ -68,7 +68,7 @@ line_list = []
append = line_list.append
period_count_dict = {}
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]
obj = Object(uid="new_")
obj["document_type"] = context.Base_translateString(portal_type)
......@@ -76,10 +76,10 @@ for portal_type in portal_type_list:
continue
line_counter = 0
for period in period_list:
if period_count.has_key(period):
if period in period_count:
obj[period] = 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]
else:
period_count_dict[period] = period_count[period]
......@@ -99,7 +99,7 @@ obj = Object(uid="new_")
obj["document_type"] = 'Total'
line_counter = 0
for period in period_list:
if period_count_dict.has_key(period):
if period in period_count_dict:
obj[period] = period_count_dict[period]
line_counter += period_count_dict[period]
else:
......
......@@ -43,7 +43,7 @@ for item in item_list:
if item_key in line_level_variation_list:
multi = False
if not sub_field_dict.has_key(item_key):
if item_key not in sub_field_dict:
# Create property dict
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key
......
......@@ -35,7 +35,7 @@ for item in item_list:
base_category = item_split[0]
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
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key
......
......@@ -21,7 +21,7 @@ if form_id is not None:
# Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields():
field_id = f.id
if request.has_key(field_id):
if field_id in request:
value = request.get(field_id)
if callable(value):
value(request)
......
......@@ -3,16 +3,16 @@
current_web_section = context.REQUEST.get('current_web_section', context)
product_list = []
if not kw.has_key('portal_type'):
if 'portal_type' not in kw:
kw['portal_type'] = 'Product'
if not kw.has_key('limit'):
if 'limit' not in kw:
kw['limit'] = limit
if not kw.has_key('all_versions'):
if 'all_versions' not in kw:
kw['all_versions'] = 1
if not kw.has_key('all_languages'):
if 'all_languages' not in kw:
kw['all_languages'] = 1
for key in ['limit','all_versions','all_languages']:
......
......@@ -5,7 +5,7 @@ from random import choice
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'
# 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):
else:
result = []
for x in wh:
if x.has_key('undo') and x['undo'] == 1:
if 'undo' in x and x['undo'] == 1:
result.pop()
else:
result.append(x.copy())
......@@ -95,7 +95,7 @@ def _updateWorkflowHistory(workflow, document, status_dict):
# Add an entry for the workflow in the history
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] = ()
# Update history
......
......@@ -7,7 +7,7 @@ items = []
# get the user information
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'])
item = {}
item['id'] = line_id
......
......@@ -7,7 +7,7 @@ items = []
# get the user information
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'])
item = {}
item['id'] = line_id
......
......@@ -7,7 +7,7 @@ items = []
# get the user information
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'])
item = {}
item['id'] = line_id
......
......@@ -50,7 +50,7 @@ fast_input_lines = []
# get the fast input form datas
for inputline in listbox:
if inputline.has_key('listbox_key'):
if 'listbox_key' in inputline:
line = {}
line['id'] = int(inputline['listbox_key'])
for data_name in input_data_names:
......
......@@ -34,7 +34,7 @@ fast_input_lines = []
# get the fast input form datas
for inputline in listbox:
if inputline.has_key('listbox_key'):
if 'listbox_key' in inputline:
line = {}
line['id'] = int(inputline['listbox_key'])
for data_name in input_data_names:
......@@ -75,7 +75,7 @@ for line in fast_input_lines:
new_1st_level_sub_items.append(new_2nd_level_item)
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
else:
structured_input_data[new_1st_level_key] = [None, None]
......
......@@ -14,7 +14,7 @@ except:
# get the user information
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'])
item = {}
item['id'] = line_id
......
......@@ -14,7 +14,7 @@ except: #XXX
# get the user information
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'])
item = {}
item['id'] = line_id
......
......@@ -14,7 +14,7 @@ except:
# get the user information
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'])
item = {}
item['id'] = line_id
......
......@@ -10,7 +10,7 @@ items = []
# get the user information
for inputline in listbox:
if inputline.has_key('listbox_key'):
if 'listbox_key' in inputline:
scenario = {}
scenario['id'] = int(inputline['listbox_key'])
scenario['title'] = inputline['scenario_title']
......@@ -55,7 +55,7 @@ for item in items:
new_1st_level_item.append(new_2nd_level_item)
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
clean_input_lines[new_1st_level_key] = new_1st_level_item
......
......@@ -36,7 +36,7 @@ except FormValidationError, validation_errors:
# Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields():
field_id = f.id
if request.has_key(field_id):
if field_id in request:
value = request.get(field_id)
if callable(value):
value(request)
......
......@@ -79,11 +79,11 @@ class ERP5CookieCrumblerTests (CookieCrumblerTests):
self.req.cookies['__ac_password'] = long_pass
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(),
'abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm')
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.assertEqual(resp.cookies['__ac']['value'],
self.credentials)
......
......@@ -70,16 +70,16 @@ class TestERP5Category(ERP5TypeTestCase):
bc = self.base_cat
if bc not in portal_categories.objectIds():
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')
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.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')
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.deep_cat2 = self.cat2['1']
......@@ -90,35 +90,35 @@ class TestERP5Category(ERP5TypeTestCase):
self.commit()
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')
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.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')
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.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')
self.person = person_module['1']
bc2 = self.base_cat2
if bc2 not in portal_categories.objectIds():
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')
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_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_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_l4 = self.efg_l3['1111']
......@@ -128,7 +128,7 @@ class TestERP5Category(ERP5TypeTestCase):
content_type_set = set(module_type.getTypeAllowedContentTypeList())
content_type_set.add('Mapped Value')
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')
predicate = organisation_module['predicate']
predicate.setCriterion('quantity', identity=None, min=None, max=None)
......@@ -139,7 +139,7 @@ class TestERP5Category(ERP5TypeTestCase):
def beforeTearDown(self):
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')
self.commitAndTic()
......@@ -149,7 +149,7 @@ class TestERP5Category(ERP5TypeTestCase):
self.commitAndTic()
organisation_module = self.getOrganisationModule()
if organisation_module.has_key('new_id'):
if 'new_id' in organisation_module:
organisation_module.manage_delObjects('new_id')
self.commitAndTic()
......
......@@ -1758,7 +1758,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
person_module = self.getPersonModule()
person = person_module.newContent(portal_type='Person')
self.assertFalse(person.hasTitle())
self.assertFalse(person.__dict__.has_key('title'))
self.assertFalse('title' in person.__dict__)
def test_24_relatedValueAccessor(self):
"""
......
......@@ -6,7 +6,7 @@ for attachment in context.getAttachmentInformationList():
# Attachments
if attachment['uid'] not in ['part_1', 'part_0']:
filename = context.getTitle()
if attachment.has_key("file_name"):
if "file_name" in attachment:
filename=attachment["file_name"]
pt = "File"
temp_base_id = 'index_'.join([attachment["uid"], str(attachment["index"])])
......
......@@ -29,7 +29,7 @@ text_search_list = []
for text, prop_dict in context.getSearchableReferenceList():
if text:
text_search_list.append(text)
if prop_dict.has_key('reference'):
if 'reference' in prop_dict:
reference_search_list.append(prop_dict['reference'])
# Search reference ticket or project
......
......@@ -2007,7 +2007,7 @@ class TestCRMMailSend(BaseTestCRM):
method_id='MailMessage_sendByActivity')
self.commit()
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:
# 5 recipients -> 5 activities
self.assertEqual(5, len(message_list))
......
......@@ -193,44 +193,44 @@ class CrmTestCase(ERP5ReportTestCase):
self.portal_categories = self.portal.portal_categories
# 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.newContent(portal_type='Category',
title='demo_group',
reference='demo_group',
id='demo_group')
# 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(
portal_type='Person',
reference='Person_1',
title='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(
portal_type='Person',
reference='Person_2',
title='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(
portal_type='Person',
reference='Person_3',
title='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(
portal_type='Organisation',
reference='Organisation_1',
title='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(
portal_type='Organisation',
reference='Organisation_2',
title='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(
portal_type='Organisation',
reference='My_organisation',
......
......@@ -8,7 +8,7 @@ if object == None:
# activity doesn't support security rights yet...
for key in ['uid','id']:
if object_property_dict.has_key(key):
if key in object_property_dict:
object_property_dict.pop(key)
object.edit(**object_property_dict)
......@@ -12,7 +12,7 @@ else:
if discussion == None:
return []
if kw.has_key("portal_type") == False:
if ("portal_type" in kw) == False:
kw['portal_type'] = "Discussion Post"
return discussion.searchFolder(**kw)
"""This script returns the Discussion Thread list that is associated to this context.
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["follow_up_uid"] = context.getUid()
......
......@@ -104,7 +104,7 @@ if newest not in BOOLEAN_MARKER:
search_mode = kw.get('search_mode', request.get('search_mode', None))
search_mode_map={'in_boolean_mode':'boolean',
'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]
return search_string
......@@ -27,7 +27,7 @@ reference_search_list = []
text_search_list = []
for text, prop_dict in context.getSearchableReferenceList():
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
follow_up_type_list = context.getPortalProjectTypeList() + context.getPortalTicketTypeList()
......
......@@ -31,7 +31,7 @@ default_sub_field_property_dict['field_type'] = 'ListField'
default_sub_field_property_dict['size'] = 1
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)
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = base_category
......
......@@ -37,12 +37,12 @@ for category_list in category_list_mapping.values():
#Take only needed attributes
for attribute in translated_attributes_list:
#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('"',"'")
if initial_value != '':
translate_value = category.get(translation_prefix+attribute,'').strip().replace('"',"'")
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',
#user should be choice 'voiture' or 'car')
if translation_dict[initial_value] != translate_value:
......
......@@ -40,7 +40,7 @@ for business_field in business_field_list:
term_list = get_term_list(business_field, reference)
#if not term_list:
# continue
if item_dict.has_key(field):
if field in item_dict:
continue
item_dict[field] = True
......
......@@ -43,7 +43,7 @@ for business_field in business_field_list:
term_list = get_term_list(business_field, reference)
#if not term_list:
# continue
if item_dict.has_key(wf_item):
if wf_item in item_dict:
continue
item_dict[wf_item] = True
......
......@@ -36,7 +36,7 @@ for portal_type in portal_type_list:
for x in remove_suffix_list:
if property_id.endswith(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
result.append({'reference':property_id,
'language':language,
......
......@@ -42,7 +42,7 @@ for business_field in template_list:
term_list = get_term_list(business_field, reference)
#if not term_list:
# continue
if item_dict.has_key(wf_item):
if wf_item in item_dict:
continue
item_dict[wf_item] = True
......
......@@ -47,9 +47,9 @@ def iterate(document, skin_path):
form_id = field.get_value('form_id')
field_id = field.get_value('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)
if selected_dict.has_key(field_path):
if field_path in selected_dict:
unproxify_dict[field.id] = None
proxify_dict[field.id] = to_rename_dict[key]
next_preview_listbox.append(
......@@ -83,7 +83,7 @@ if update:
extra_kw = {}
for line in next_preview_listbox:
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_selected_new_%03i" % count] = line["selected"]
count += 1
......
......@@ -34,7 +34,7 @@ def callback(o,seldict):
form_name = o.absolute_url() # TODO it could be done much better
# assumes that name of form is unique enough
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')]
if form_name not in old_list:
old_list.append(form_name)
......
......@@ -146,7 +146,7 @@ except FormValidationError as validation_errors:
# Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields():
field_id = f.id
if request.has_key(field_id):
if field_id in request:
value = request.get(field_id)
if callable(value):
value(request)
......
......@@ -47,7 +47,7 @@ except FormValidationError as validation_errors:
# Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields():
field_id = f.id
if request.has_key(field_id):
if field_id in request:
value = request.get(field_id)
if callable(value):
value(request)
......@@ -179,11 +179,11 @@ def editMatrixBox(matrixbox_field, matrixbox):
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
if cell_value_dict.has_key('variated_property'):
if 'variated_property' in cell_value_dict:
# For Variated Properties
value = 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
# first element of mapped_value_property_list
# XXX Kato: What? Why?
......
......@@ -1096,7 +1096,7 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
selection_params=selection_params,
request_field=not use_relation_form_page_template,
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)
except AttributeError as error:
# Do not crash if field configuration is wrong.
......@@ -2110,7 +2110,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
value=default_field_value,
key='field_%s_%s' % (editable_field.id, brain_uid))
# 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"] = \
Base_translateString(field_errors['%s_%s' % (editable_field.id, brain_uid)].error_text)
......
......@@ -941,7 +941,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
'form_view'
)
self.assertFalse(result_dict['_embedded']['_view'].has_key('_actions'))
self.assertFalse('_actions' in result_dict['_embedded']['_view'])
@simulate('Base_getRequestUrl', '*args, **kwargs',
......
......@@ -1092,7 +1092,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase):
for key in e_period.keys():
e_value = e_period[key]
#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]
is_float = 0
try:
......
......@@ -12,7 +12,7 @@ if user is None:
kw['owner'] = user
kw['portal_type'] = context.getPortalMyDocumentTypeList()
if not kw.has_key('validation_state'):
if 'validation_state' not in kw:
kw['validation_state'] = "!=embedded"
return context.portal_catalog.countResults(**kw)
......@@ -12,7 +12,7 @@ if user is None:
kw['portal_type'] = context.getPortalMyDocumentTypeList()
kw['owner'] = user
if not kw.has_key('validation_state'):
if 'validation_state' not in kw:
kw['validation_state'] = "!=embedded"
return context.portal_catalog(**kw)
......@@ -13,7 +13,7 @@
Type-based.
"""
# convert language to lowercase
if property_dict.has_key('language'):
if 'language' in property_dict:
property_dict['language'] = property_dict['language'].lower()
language = property_dict.get('language', 'en')
......
......@@ -167,7 +167,7 @@ class TestInvoiceMixin(TestPackingListMixin):
'product_line/apparel'))
account_module = portal.account_module
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_type=account_type)
account.validate()
......
......@@ -35,7 +35,7 @@ for ss in source_section_list:
else:
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].setSourceSectionValue(ss)
......
......@@ -21,7 +21,7 @@ if dialog.has_field('your_item_extra_property_list'):
for line in kw.get('listbox'):
if line.has_key('listbox_key'):
if 'listbox_key' in line:
item_reference = line.get('reference')
if item_reference:
item = context.portal_catalog.getResultValue(
......
......@@ -21,7 +21,7 @@ kw = worklist.getIdentityCriterionDict()
portal_type_list = workflow.getPortalTypeListForWorkflow()
if not portal_type_list:
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
kw['portal_type'] = portal_type_list
......
......@@ -28,7 +28,7 @@ def getWebSectionPredicateValueList():
# remove leading 'follow_up' from category
if category.startswith('follow_up/'):
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].append({'uid': section['uid'], 'relative_url':section['relative_url']})
# get base_categories we care for
......
......@@ -25,7 +25,7 @@ except FormValidationError, validation_errors:
# Make sure editors are pushed back as values into the REQUEST object
for f in form.get_fields():
field_id = f.id
if request.has_key(field_id):
if field_id in request:
value = request.get(field_id)
if callable(value):
value(request)
......
......@@ -7,7 +7,7 @@ result_listbox = []
# context.log(str(kw))
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']
#else:
# if context.REQUEST.get('active_process', None) not in ('None', None):
......
......@@ -108,7 +108,7 @@ else:
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][1][column_name] = property
......@@ -147,7 +147,7 @@ else:
imported_line_property_dict = {}
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]
if property_value:
# Create a new property value
......
......@@ -94,7 +94,7 @@ class PaypalService(XMLObject):
param_dict = REQUEST.form
LOG("PaypalService", DEBUG, param_dict)
param_dict["cmd"] = "_notify-validate"
if param_dict.has_key("service"):
if "service" in param_dict:
param_dict.pop("service")
param_list = urlencode(param_dict)
paypal_url = self.getLinkUrlString()
......
......@@ -199,7 +199,7 @@ class PaySheetTransaction(Invoice):
if movement.getTotalPrice() not in (0, None):
# remove movement with 0 total_price
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].append(movement)
for trade_phase in movement_list_trade_phase_dic.keys():
......
......@@ -14,7 +14,7 @@ context.manage_delObjects(id_list)
# create Pay Sheet Lines
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
from ZTUtils import make_query
redirect_url = '%s/%s?%s' % (context.absolute_url(), 'view', make_query())
......
......@@ -80,10 +80,10 @@ for model_line in model_line_list:
salary_range = 'no_slice'
# 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_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_relative_url = tuple_dict['salary_range_relative_url']
new_uid = "new_%s" % id_
......@@ -108,7 +108,7 @@ for model_line in model_line_list:
for object_key in model_line.getSalaryRangeList():
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']))
......@@ -132,7 +132,7 @@ def sortByIntIndexDescending(x, y):
sortByDefaultSortMethod = sortByIntIndexAscending
if kw.has_key('sort_on'):
if 'sort_on' in kw:
sort_on = kw['sort_on']
if sort_on[0][0] == 'title' and sort_on[0][1]=='ascending':
line_list.sort(sortByTitleAscending)
......
......@@ -78,9 +78,9 @@ for paysheet_line in paysheet_line_list:
salary_range_slice = cell.getSalaryRange()
if salary_range_slice is None:
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
if tuple_dict.has_key('salary_range'):
if 'salary_range' in tuple_dict:
slice_title=tuple_dict['salary_range']
object_dict[salary_range_slice]={
'slice':slice_title,
......@@ -117,7 +117,7 @@ for paysheet_line in paysheet_line_list:
for object_key in paysheet_line.getSalaryRangeList():
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']))
......@@ -137,7 +137,7 @@ def sortByIntIndexDescending(x, y):
sortByDefaultSortMethod = sortByIntIndexAscending
if kw.has_key('sort_on'):
if 'sort_on' in kw:
sort_on = kw['sort_on']
if sort_on[0][0] == 'title' and sort_on[0][1]=='ascending':
line_list.sort(sortByTitleAscending)
......
......@@ -22,14 +22,14 @@ for line in line_dict_list:
string_to_display.append(rightPad(line['title'], 40))
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_quantity']), 24))
else:
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_quantity']), 24))
else:
......
......@@ -1428,16 +1428,16 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
self.assertEqual(len(model_reference_dict), 3) # there is 4 model but two
# models have the same
# 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],
['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],
['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],
['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 :
object_list = paysheet.getInheritedObjectValueList(portal_type_list=\
......
......@@ -14,7 +14,7 @@ for item in item_list:
item_split = string.split(item_value, '/')
item_key = string.join(item_split[:split_depth] , '/' )
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
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key
......
......@@ -14,7 +14,7 @@ result = []
variation_category_dict = {}
for variation_category in reference_variation_category_list:
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 )
else:
variation_category_dict[base_category] = [variation_category]
......
......@@ -14,7 +14,7 @@ for item in item_list:
item_split = string.split(item_value, '/')
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
sub_field_property_dict = default_sub_field_property_dict.copy()
sub_field_property_dict['key'] = item_key
......
......@@ -14,7 +14,7 @@ task_items = []
# get the user information
for task in listbox:
if task.has_key('listbox_key'):
if 'listbox_key' in task:
task_id = int(task['listbox_key'])
task_dict = {}
task_dict['id'] = task_id
......
......@@ -54,7 +54,7 @@ else:
project_to_display_dict = here.monthly_project_to_display_dict.get(string_index, {})
if depth == 1:
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:
parent_category_list = parent.getMembershipCriterionCategoryList()
category_list = []
......@@ -63,12 +63,12 @@ else:
# need to be displayed for this month
for parent_category in parent_category_list:
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)
category_child_list = parent_category_object.contentValues(portal_type=project_line_portal_type)
#category_list.append(parent_category_object)
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)
......
......@@ -37,7 +37,7 @@ def getTotalQuantity(line,worker):
for child in child_list:
child_quantity = getTotalQuantity(child,worker)
for key,value in child_quantity.items():
if not quantity.has_key(key):
if key not in quantity:
quantity[key] = 0
quantity[key] = quantity[key] + value
else:
......@@ -73,7 +73,7 @@ for year,month in month_list:
listbox_line['month'] = month
for worker in worker_list:
quantity = 0
if worker_quantity[worker].has_key((year,month)):
if (year,month) in worker_quantity[worker]:
quantity = worker_quantity[worker][(year,month)]
worker_title = 'unknown'
if worker is not None:
......
......@@ -25,6 +25,6 @@ else:
membership_criterion_category = membership_criterion_category_list[0]
assert membership_criterion_category.startswith('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])
return result_list
......@@ -127,7 +127,7 @@ for task_line in result_list:
project_relative_url = project_dict['relative_url']
full_date_total_worker_quantity_dict[source_relative_url] = \
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=1,
string_index = full_date_string,
......@@ -153,7 +153,7 @@ for task_line in result_list:
project_to_display_dict = monthly_project_to_display_dict.setdefault(string_index, {})
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=1,
string_index = string_index,
......
......@@ -4,15 +4,15 @@ source_project_uid_list = [x.uid for x in context.portal_catalog(
from Products.ZSQLCatalog.SQLCatalog import Query
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'],
'range' : 'min'}
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'],
'range' : 'ngt'}
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']
task_list = [x.getObject() for x in \
......
......@@ -4,18 +4,18 @@ source_project_uid_list = [x.uid for x in context.portal_catalog(
from Products.ZSQLCatalog.SQLCatalog import Query
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'],
'range' : 'min'}
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'],
'range' : 'ngt'}
sql_kw['delivery.stop_date'] = Query(**query_kw)
# Make sure to not include "confirmed tasks" in any case, because in
# 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_report_simulation_state = kw['simulation_state']
else:
......
......@@ -26,7 +26,7 @@ requirements_items = []
# get the user information
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 = {}
requirement['id'] = requirement_line_id
......@@ -76,7 +76,7 @@ for requirement_item in requirements_items:
new_1st_level_requirement.append(new_2nd_level_feat)
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
clean_requirements[new_1st_level_requirement_title] = new_1st_level_requirement
clean_requirements_key_list.append(new_1st_level_requirement_title)
......
......@@ -3,7 +3,7 @@ log('task_list','starting')
task_module = context.getDefaultModule('Task Report')
log('task_list','next1')
task_list = []
if not kw.has_key('parent_uid'):
if 'parent_uid' not in kw:
kw['parent_uid'] = task_module.getUid()
log('task_list','next2')
log('context.getPath()',context.getPath())
......
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):
rule.validate()
# 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(
title='Organisation_1',
id='Organisation_1')
# 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(
title='Organisation_2',
id='Organisation_2')
# 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(
portal_type='Project',
reference='Project_1',
......@@ -82,7 +82,7 @@ class TestProject(ERP5TypeTestCase):
# Create resources
module = self.portal.product_module
if not module.has_key('development'):
if 'development' not in module:
module.newContent(
portal_type='Product',
id='development',
......
......@@ -71,14 +71,14 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
rule.validate()
# 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(
portal_type='Organisation',
reference='Organisation_1',
title='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(
portal_type='Organisation',
reference='Organisation_2',
......@@ -86,13 +86,13 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
id='Organisation_2')
# 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(
portal_type='Person',
reference='Person_1',
title='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(
portal_type='Person',
reference='Person_2',
......@@ -100,7 +100,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
id='Person_2')
# 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(
portal_type='Project',
reference='Project_1',
......@@ -114,7 +114,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
project.newContent(portal_type='Project Line',
id='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(
portal_type='Project',
reference='Project_2',
......@@ -125,7 +125,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
# create unit categories
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(
portal_type='Category',
title=unit_id.title(),
......@@ -134,7 +134,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
# Create resources
module = self.portal.product_module
if not module.has_key('development'):
if 'development' not in module:
module.newContent(
portal_type='Product',
id='development',
......@@ -142,7 +142,7 @@ class TestTaskReportingMixin(ERP5ReportTestCase):
reference='ref 1',
quantity_unit='day'
)
if not module.has_key('consulting'):
if 'consulting' not in module:
module.newContent(
portal_type='Product',
id='consulting',
......
......@@ -42,16 +42,16 @@ class TestResearchItemSummaryReport(TestTaskReportingMixin):
super(TestResearchItemSummaryReport, self).afterSetUp()
ledger_base_category = self.portal.portal_categories.ledger
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(
portal_type='Category', title=category_id.title(),
reference=category_id, id=category_id)
# 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",
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",
id="Item_2", portal_type="Research Item")
......
......@@ -11,7 +11,7 @@ if image_caption in [None, ""]:
image_caption = chapter_title
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']
int_index = listbox[-1].int_index + 1
else:
......
......@@ -3,7 +3,7 @@
"""
session = context.ERP5Site_acquireRunMyDocsSession()
if session.has_key('listbox'):
if 'listbox' in session:
listbox = session['listbox']
else:
listbox = []
......
......@@ -444,7 +444,7 @@ class TestBPMImplementation(TestBPMDummyDeliveryMovementMixin):
context_movement = self.createMovement()
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):
business_path = self.createTradeModelPath()
......
......@@ -112,7 +112,7 @@ class SyncMLSubscription(XMLObject):
activate_kw : activity parameters to pass to activate call
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)
packet_size = search_kw.pop('packet_size', 30)
limit = packet_size * search_kw.pop('activity_count', 100)
......@@ -277,7 +277,7 @@ class SyncMLSubscription(XMLObject):
syncml_logger.debug("--> calling getAndActivate packet size = %s, limit = %s",
packet_size, limit)
# 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
else:
first_call = False
......
......@@ -292,7 +292,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
* machin = getattr (object, methos)
* machin()
"""
if kw.has_key(key):
if key in kw:
new_value = kw[key]
if new_value != None:
if isinstance(new_value, str):
......@@ -338,7 +338,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
erp5_site_path = erp5_site.absolute_url(relative=1)
# The object is a ShopOrder
if kw.has_key('country'):
if 'country' in kw:
object.setStartDate(kw['target_start_date'])
object.setStopDate(kw['target_stop_date'])
# Find the organisation and the person folder
......@@ -379,7 +379,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
previous_owner_type = 'o' # Organisation is more important than the person
# This is a particular case where the user put
# 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()
#if len(previous_owner_type) == 0:
# previous_owner_type = None
......@@ -387,11 +387,11 @@ class ERP5ShopOrderConduit(ERP5Conduit):
# Try to know the type of the current storever customer
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'
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'
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'
if len(owner_type) == 0:
owner_type = None
......@@ -511,11 +511,11 @@ class ERP5ShopOrderConduit(ERP5Conduit):
# elif previous_address.strip().lower() != kw['address'].strip().lower():
# 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())
if kw.has_key('address') and kw['address'] != None:
if 'address' in kw and kw['address'] != None:
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'])
# # TODO : set the person products interest (storever, etc)
# Search the country in the region category
......@@ -525,15 +525,15 @@ class ERP5ShopOrderConduit(ERP5Conduit):
person_object.setDefaultAddressRegion(region_path)
# else:
# # 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'])
if kw.has_key('phone') and kw['phone'] != None:
if 'phone' in kw and kw['phone'] != None:
person_object.setDefaultTelephoneText(kw['phone'])
# # TODO : Don't work
# person_object.setDefaultCareerRole("client")
# Split the name to give at least a required LastName
# 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(" ")
person_object.setLastName((splitted_name[-1]).title())
if len(splitted_name) > 1:
......@@ -545,13 +545,13 @@ class ERP5ShopOrderConduit(ERP5Conduit):
if owner_type.find('o') != -1 and previous_owner_type =='o':
# # TODO : fix this
# 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.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'])
# 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, '')
org_object.setRole("client")
......@@ -570,17 +570,17 @@ class ERP5ShopOrderConduit(ERP5Conduit):
object.setDestination("organisation/" + owner_id)
object.setDestinationSection("organisation/" + owner_id)
# 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.setCorporateName(kw['organisation'].title())
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'])
if kw.has_key('address') and kw['address'] != None:
if 'address' in kw and kw['address'] != None:
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())
if kw.has_key('zipcode') and kw['zipcode'] != None:
if 'zipcode' in kw and kw['zipcode'] != None:
org_object.setDefaultAddressZipCode(kw['zipcode'])
# Search the country in the region category
if kw['country'] != None:
......@@ -589,13 +589,13 @@ class ERP5ShopOrderConduit(ERP5Conduit):
org_object.setDefaultAddressRegion(region_path)
# else:
# # 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'])
if kw.has_key('phone') and kw['phone'] != None:
if 'phone' in kw and kw['phone'] != None:
org_object.setDefaultTelephoneText(kw['phone'])
# 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'])
# Set the Title because its required
object.setTitle("Storever Order " + str(kw['order_id']))
......
......@@ -111,11 +111,11 @@ class WebServiceRequest(XMLObject, ZopePageTemplate):
if REQUEST is not None:
return self.view()
#LOG("_call__", 300, kw)
if kw.has_key("id"):
if "id" in kw:
kw[self.getIDParameterName()] = str(kw.pop("id"))
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)
object_list = []
......
......@@ -68,7 +68,7 @@ class NewEchoDictTarget:
self.current_parser = subtag
else:
if self._current_object is not None and \
not self._current_object.has_key(value):
value not in self._current_object:
# Create default value
self._current_object[value] = ""
self._current_key = value
......@@ -102,7 +102,7 @@ class NewEchoDictTarget:
def data(self, data):
if self._current_key and len(data.strip()):
# 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
self._current_object[self._current_key] = data
......@@ -148,7 +148,7 @@ class EchoDictTarget:
if root:
self._current_object = {}
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_key = value
else:
......@@ -171,7 +171,7 @@ class EchoDictTarget:
def data(self, data):
if self._current_key and len(data.strip()):
# 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
self._current_object[self._current_key] = data
......
......@@ -25,7 +25,7 @@ def createCategory(object_mapping=None, category=""):
mapping_dict = {}
destination_list = []
for line in listbox:
if line.has_key('listbox_key'):
if 'listbox_key' in line:
line_id = line['listbox_key']
mapping_dict[line_id] = line
if line["destination_reference_text"] != "":
......
......@@ -14,14 +14,14 @@ def getMappingChildUid(mapping):
def resetListBox(listbox, uid_list):
for line in listbox:
if line.has_key('listbox_key'):
if 'listbox_key' in line:
line_id = line['listbox_key']
if line_id in uid_list:
line['destination_reference'] = ""
return listbox
for line in listbox:
if line.has_key('listbox_key'):
if 'listbox_key' in line:
line_id = line['listbox_key']
mapping_dict[line_id] = line
if line["destination_reference_text"] != "":
......
......@@ -73,11 +73,11 @@ if len(client_dict):
line_total_amount = 0
for period in period_list:
# 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)
line_total_amount += client_dict[client_title][period]['amount']
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']
else:
period_counter_dict['Amount %s' %(period)] = client_dict[client_title][period]['amount']
......@@ -85,7 +85,7 @@ if len(client_dict):
obj['Amount %s' %(period)] = 0
obj['total amount'] = round(line_total_amount, 2)
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
else:
period_counter_dict['total amount'] = line_total_amount
......@@ -94,7 +94,7 @@ if len(client_dict):
if report_group_by == "both":
product_lines_list = []
# one line per product
if product_dict.has_key(client_title):
if client_title in product_dict:
line_product_dict = product_dict[client_title]
for product_title in line_product_dict.keys():
obj = Object(uid="new_")
......@@ -102,7 +102,7 @@ if len(client_dict):
line_total_amount = 0
line_total_quantity = 0
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['Quantity %s' %(period)] = line_product_dict[product_title][period]['quantity']
obj['Quantity Unit %s' %(period)] = line_product_dict[product_title][period]['quantity_unit']
......@@ -110,7 +110,7 @@ if len(client_dict):
line_total_amount += line_product_dict[product_title][period]['amount']
line_total_quantity += line_product_dict[product_title][period]['quantity']
# 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)] + \
line_product_dict[product_title][period]['amount']
else:
......@@ -124,7 +124,7 @@ if len(client_dict):
obj['total quantity'] = line_total_quantity
obj['total amount'] = round(line_total_amount, 2)
# 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
else:
period_counter_dict['total amount'] = line_total_amount
......@@ -142,7 +142,7 @@ else:
line_total_amount = 0
line_total_quantity = 0
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['Quantity %s' %(period)] = product_dict[product_title][period]['quantity']
obj['Quantity Unit %s' %(period)] = product_dict[product_title][period]['quantity_unit']
......@@ -150,7 +150,7 @@ else:
line_total_amount += product_dict[product_title][period]['amount']
line_total_quantity += product_dict[product_title][period]['quantity']
# 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']
else:
period_counter_dict['Amount %s' %(period)] = product_dict[product_title][period]['amount']
......@@ -162,7 +162,7 @@ else:
obj['total quantity'] = line_total_quantity
obj['total amount'] = round(line_total_amount,2)
# 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
else:
period_counter_dict['total amount'] = line_total_amount
......
......@@ -35,13 +35,13 @@ for result in document_list:
else:
client_title = result['source_section_title']
# 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] = {}
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)
else:
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] = {}
else:
line_dict = product_dict[client_title]
......@@ -54,12 +54,12 @@ for result in document_list:
for line in line_list:
# FIXME: if two resources have the same title, do we want to group ?
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,
"quantity" : line.quantity or 0,
"quantity_unit" : translate(line.strict_quantity_unit_title)}}
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,
"quantity" : line.quantity or 0,
"quantity_unit" : translate(line.strict_quantity_unit_title)}
......
......@@ -78,7 +78,7 @@ class TestTradeReports(ERP5ReportTestCase):
('demo_site_A', 'DEMO-SITE-A'),
('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(
portal_type='Category',
title=site_id,
......@@ -87,7 +87,7 @@ class TestTradeReports(ERP5ReportTestCase):
id=site_id)
# Colour categories
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(
portal_type='Category',
title=colour_id,
......@@ -96,7 +96,7 @@ class TestTradeReports(ERP5ReportTestCase):
# create group categories
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(
portal_type='Category',
title=group_id,
......@@ -105,7 +105,7 @@ class TestTradeReports(ERP5ReportTestCase):
# create use categories
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(
portal_type='Category',
title=use_id,
......@@ -113,7 +113,7 @@ class TestTradeReports(ERP5ReportTestCase):
id=use_id)
# currencies
if not self.portal.currency_module.has_key('EUR'):
if 'EUR' not in self.portal.currency_module:
self.portal.currency_module.newContent(
portal_type='Currency',
id='EUR',
......@@ -122,7 +122,7 @@ class TestTradeReports(ERP5ReportTestCase):
# product line
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(
portal_type='Category',
title=product_line,
......@@ -131,7 +131,7 @@ class TestTradeReports(ERP5ReportTestCase):
)
# 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(
portal_type='Organisation',
reference='Organisation_1',
......@@ -145,7 +145,7 @@ class TestTradeReports(ERP5ReportTestCase):
default_address_street_address='1 Organisation Street',
default_address_zip_code='111',
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(
portal_type='Organisation',
reference='Organisation_2',
......@@ -154,7 +154,7 @@ class TestTradeReports(ERP5ReportTestCase):
group='g2',
site='demo_site_B')
# 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(
portal_type='Organisation',
reference='Organisation_3',
......@@ -162,12 +162,12 @@ class TestTradeReports(ERP5ReportTestCase):
id='Organisation_3',)
# 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(
portal_type='Category',
id='mass')
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(
portal_type='Category',
title=unit_id.title(),
......@@ -175,7 +175,7 @@ class TestTradeReports(ERP5ReportTestCase):
id=unit_id)
# 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(
portal_type='Quantity Unit Conversion Group',
id='mass_conversion_group',
......@@ -216,7 +216,7 @@ class TestTradeReports(ERP5ReportTestCase):
variation_base_category_list=['colour'],
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(
portal_type='Service',
id='service_a',
......
......@@ -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='/')
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() + '/'
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:
no_web_page = False
form_id = 'view'
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'
no_reference = not request.has_key('web_page_reference') 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_reference = 'web_page_reference' not in request or request['web_page_reference'] is None or not request['web_page_reference']
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 validator:
......
......@@ -171,7 +171,7 @@ class WebSite(WebSection):
path = section.getPhysicalPath()
for i in range(0, len(path)):
sub_path = tuple(path[0:i])
if section_dict.has_key(sub_path):
if sub_path in section_dict:
del section_dict[sub_path]
section_list = section_dict.values()
......
......@@ -12,7 +12,7 @@ if username is not None:
)
)
REQUEST = portal.REQUEST
if REQUEST.has_key('portal_skin'):
if 'portal_skin' in REQUEST:
portal.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/')
......
......@@ -12,7 +12,7 @@ if username is not None:
)
)
REQUEST = portal.REQUEST
if REQUEST.has_key('portal_skin'):
if 'portal_skin' in REQUEST:
portal.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/')
......
......@@ -2,19 +2,19 @@
portal = context.getPortalObject()
# 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')
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')
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')
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')
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.web_page_module.manage_delObjects(
......@@ -22,7 +22,7 @@ portal.web_page_module.manage_delObjects(
if x.getTitle().startswith('test_')])
# 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')
else:
person = portal.person_module.test_webmaster
......@@ -47,6 +47,6 @@ if person.getValidationState() != 'validated':
person.validate()
# 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')
return 'Reset Successfully.'
......@@ -81,6 +81,8 @@ class Python3StyleTest(ERP5TypeTestCase):
def test_importFixApplied(self):
self._testFixer('import')
def test_hasKeyFixApplied(self):
self._testFixer('has_key')
def test_suite():
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