Commit 5252fde2 authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'nexedi/master' into zope4py2

parents 2e25ded9 c98ecf4a
......@@ -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
......
......@@ -5,7 +5,7 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
portal = context.getPortalObject()
accounting_module = portal.accounting_module
year = 2005
default_date = DateTime(year, 01, 01)
default_date = DateTime(year, 1, 1)
business_process = portal.portal_catalog.getResultValue(
reference=('default_erp5_business_process', # erp5_configurator
......
......@@ -98,8 +98,8 @@ for month in range(1, month_count + 1):
source_payment=getBankAccountByTitle('My default bank account'),
destination_section=getOrganisationByTitle(client_title),
created_by_builder=1,
start_date=DateTime(year, month, day, 01, 01) + 10,
stop_date=DateTime(year, month, day, 01, 01) + 10,
start_date=DateTime(year, month, day, 1, 1) + 10,
stop_date=DateTime(year, month, day, 1, 1) + 10,
causality_value=tr,
resource=euro_resource,
)
......
......@@ -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
......
......@@ -208,7 +208,7 @@ class CertificateAuthorityTool(BaseTool):
cert = os.path.join(self.certificate_authority_path, 'certs',
new_id + '.crt')
try:
os.close(os.open(key, os.O_CREAT | os.O_EXCL, 0600))
os.close(os.open(key, os.O_CREAT | os.O_EXCL, 0o600))
popenCommunicate([self.openssl_binary, 'req', '-utf8', '-nodes', '-config',
self.openssl_config, '-new', '-keyout', key, '-out', csr, '-days',
'3650'], '%s\n' % common_name, stdin=subprocess.PIPE)
......
......@@ -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
......
......@@ -822,7 +822,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
group='my_group')
accounting_period = organisation.newContent(
portal_type='Accounting Period',
start_date=DateTime(2001, 01, 01),
start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2002, 12, 31))
self.assertEqual(accounting_period.getSimulationState(), 'draft')
......@@ -1054,8 +1054,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepAccountingTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction',
start_date=DateTime(2001, 01, 01),
stop_date=DateTime(2001, 01, 01))
start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction)
......@@ -1186,8 +1186,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepSaleInvoiceTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent(
portal_type='Sale Invoice Transaction',
start_date=DateTime(2001, 01, 01),
stop_date=DateTime(2001, 01, 01))
start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction)
......@@ -1329,8 +1329,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepPurchaseInvoiceTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent(
portal_type='Purchase Invoice Transaction',
start_date=DateTime(2001, 01, 01),
stop_date=DateTime(2001, 01, 01))
start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction)
......@@ -1476,8 +1476,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepPaymentTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
start_date=DateTime(2001, 01, 01),
stop_date=DateTime(2001, 01, 01))
start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction)
......@@ -1621,29 +1621,29 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
accounting_transaction_x_related_to_a = self.portal.\
accounting_module.newContent(
portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01),
stop_date=DateTime(2010, 06, 01))
start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 6, 1))
accounting_transaction_y_related_to_a = self.portal.\
accounting_module.newContent(
portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01),
stop_date=DateTime(2010, 06, 01))
start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 6, 1))
accounting_transaction_a = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01),
stop_date=DateTime(2010, 06, 01))
start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 6, 1))
accounting_transaction_b = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01),
stop_date=DateTime(2010, 06, 01))
start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 6, 1))
accounting_transaction_c = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01),
stop_date=DateTime(2010, 06, 01))
start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 6, 1))
accounting_transaction_x_related_to_a.setCausalityValue(\
accounting_transaction_a)
......
......@@ -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)
......
......@@ -138,7 +138,7 @@ class TestAlarm(ERP5TypeTestCase):
right_first_date = DateTime(self.date_format % (2006,10,6,15,00,00))
now = DateTime(self.date_format % (2006,10,6,15,00,00))
right_second_date = DateTime(self.date_format % (2006,10,6,21,00,00))
right_third_date = DateTime(self.date_format % (2006,10,7,06,00,00))
right_third_date = DateTime(self.date_format % (2006,10,7,6,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,7,10,00,00))
alarm = self.newAlarm(enabled=True)
hour_list = (6,10,15,21)
......@@ -234,8 +234,8 @@ class TestAlarm(ERP5TypeTestCase):
def test_09_SomeMonthDaysSomeHours(self):
"""- every 1st and 15th every month, at 12 and 14"""
right_first_date = DateTime(self.date_format % (2006,10,01,12,00,00))
right_second_date = DateTime(self.date_format % (2006,10,01,14,00,00))
right_first_date = DateTime(self.date_format % (2006,10,1,12,00,00))
right_second_date = DateTime(self.date_format % (2006,10,1,14,00,00))
right_third_date = DateTime(self.date_format % (2006,10,15,12,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,15,14,00,00))
alarm = self.newAlarm(enabled=True)
......@@ -247,9 +247,9 @@ class TestAlarm(ERP5TypeTestCase):
def test_10_OnceEvery2Month(self):
"""- every 1st day of every 2 month, at 6"""
right_first_date = DateTime(self.date_format % (2006,10,01,6,00,00))
right_second_date = DateTime(self.date_format % (2006,12,01,6,00,00))
right_third_date = DateTime(self.date_format % (2007,2,01,6,00,00))
right_first_date = DateTime(self.date_format % (2006,10,1,6,00,00))
right_second_date = DateTime(self.date_format % (2006,12,1,6,00,00))
right_third_date = DateTime(self.date_format % (2007,2,1,6,00,00))
alarm = self.newAlarm(enabled=True)
alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityMonthDayList((1,))
......
......@@ -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)
......
......@@ -799,7 +799,7 @@ class TestERP5Base(ERP5TypeTestCase):
"""Tests dates on Person objects.
"""
pers = self.getPersonModule().newContent(portal_type='Person')
birthday = DateTime(1999, 01, 01)
birthday = DateTime(1999, 1, 1)
now = DateTime()
pers.edit(birthday = birthday)
self.assertEqual(birthday, pers.getBirthday())
......@@ -814,7 +814,7 @@ class TestERP5Base(ERP5TypeTestCase):
"""Tests dates on Organisation objects.
"""
org = self.getOrganisationModule().newContent(portal_type='Organisation')
start_date = DateTime(1999, 01, 01)
start_date = DateTime(1999, 1, 1)
now = DateTime()
org.edit(start_date = start_date)
self.assertEqual(start_date, org.getStartDate())
......@@ -964,7 +964,7 @@ class TestERP5Base(ERP5TypeTestCase):
subordination_value=first_organisation,
start_date=DateTime(1996, 9, 9))
another_cancelled_career.cancel()
self.assertEqual(DateTime(2001, 01, 01),
self.assertEqual(DateTime(2001, 1, 1),
person.Person_getCareerStartDate(
subordination_relative_url=first_organisation.getRelativeUrl()))
......
......@@ -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):
"""
......
......@@ -384,7 +384,7 @@ class TestDateTimeField(ERP5TypeTestCase):
.xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0])
def test_render_odt_variable(self):
value = DateTime(2010, 12, 06, 10, 23, 32, 'GMT+5')
value = DateTime(2010, 12, 6, 10, 23, 32, 'GMT+5')
self.field.values['default'] = value
node = self.field.render_odt_variable(as_string=False)
self.assertEqual(node.get('{%s}value-type' % NSMAP['office']), 'date')
......
......@@ -280,7 +280,7 @@ class TestPreferences(PropertySheetTestCase):
portal_workflow.doActionFor(
person1, 'enable_action', wf_id='preference_workflow')
self.assertEqual(person1.getPreferenceState(), 'enabled')
person1.setPreferredAccountingTransactionAtDate(DateTime(2005, 01, 01))
person1.setPreferredAccountingTransactionAtDate(DateTime(2005, 1, 1))
pref_tool.setPreference(
'preferred_accounting_transaction_at_date', DateTime(2004, 12, 31))
self.tic()
......@@ -320,7 +320,7 @@ class TestPreferences(PropertySheetTestCase):
# create a pref for user_b
user_b_1 = portal_preferences.newContent(
id='user_b_1', portal_type='Preference')
user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 02, 02))
user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 2, 2))
self.tic()
# enable this preference
......
......@@ -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:
......
......@@ -46,7 +46,7 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase):
"""
self.dsn_module = self.portal.getDefaultModuleValue("DSN Monthly Report")
self.setTimeZoneToUTC()
self.pinDateTime(DateTime(2015, 12, 01))
self.pinDateTime(DateTime(2015, 12, 1))
# Create the id_group 'dsn_event_counter'
self.portal.portal_ids.generateNewId(id_group='dsn_event_counter', id_generator='continuous_integer_increasing')
......
......@@ -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()
......
......@@ -281,16 +281,16 @@ class TestInvoice(TestInvoiceMixin):
self.assertEqual(other_resource,
invoice_movement.getResourceValue())
order_line.setStartDate(DateTime(2001, 02, 03))
order_line.setStartDate(DateTime(2001, 2, 3))
self.tic()
invoice_movement = invoice_applied_rule.contentValues()[0]
self.assertEqual(DateTime(2001, 02, 03),
self.assertEqual(DateTime(2001, 2, 3),
invoice_movement.getStartDate())
order_line.setStopDate(DateTime(2002, 03, 04))
order_line.setStopDate(DateTime(2002, 3, 4))
self.tic()
invoice_movement = invoice_applied_rule.contentValues()[0]
self.assertEqual(DateTime(2002, 03, 04),
self.assertEqual(DateTime(2002, 3, 4),
invoice_movement.getStopDate())
@newSimulationExpectedFailure
......@@ -478,20 +478,20 @@ class TestInvoice(TestInvoiceMixin):
self.assertEqual(456,
invoice_transaction_movement.getQuantity())
order_line.setStartDate(DateTime(2001, 02, 03))
order_line.setStartDate(DateTime(2001, 2, 3))
self.tic()
self.assertEqual(3, len(invoice_transaction_applied_rule))
invoice_transaction_movement = getIncomeSimulationMovement(
invoice_transaction_applied_rule)
self.assertEqual(DateTime(2001, 02, 03),
self.assertEqual(DateTime(2001, 2, 3),
invoice_transaction_movement.getStartDate())
order_line.setStopDate(DateTime(2002, 03, 04))
order_line.setStopDate(DateTime(2002, 3, 4))
self.tic()
self.assertEqual(3, len(invoice_transaction_applied_rule))
invoice_transaction_movement = getIncomeSimulationMovement(
invoice_transaction_applied_rule)
self.assertEqual(DateTime(2002, 03, 04),
self.assertEqual(DateTime(2002, 3, 4),
invoice_transaction_movement.getStopDate())
def test_Invoice_viewAsODT(self):
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment