Yoshinori Okuji
2009-04-02 03:51:34 UTC
I don't understand why you need to *deprecate* cmp.
YO
YO
Author: jm
Date: Wed Apr 1 17:01:12 2009
New Revision: 26242
URL: http://svn.erp5.org?rev=26242&view=rev
Deprecate sort_method parameter in DomainTool.searchPredicateList since cmp
parameter in sorting methods is slow and deprecated. Add new
sort_key_method parameter that is passed as key parameter to list.sort.
erp5/trunk/products/ERP5/Tool/DomainTool.py
erp5/trunk/products/ERP5/tests/testDomainTool.py
Modified: erp5/trunk/products/ERP5/Tool/DomainTool.py
http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/DomainTool.py?rev=26242&r
1=26241&r2=26242&view=diff
===========================================================================
=== --- erp5/trunk/products/ERP5/Tool/DomainTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/DomainTool.py [utf8] Wed Apr 1 17:01:12
ignored_category_list=None,
tested_base_category_list=None,
filter_method=None, acquired=1,
# XXX: about "strict" parameter: This is a transition parameter,
# allowing someone hitting a bug to revert to original behaviour
easily. # It is not a correct name, as pointed out by Jerome. But instead
"""
Search all predicates which corresponds to this particular
context.
-
- - The sort_method parameter allows to give a method which will be
- used in order to sort the list of predicates found. The most
+
+ - sort_method parameter is deprecated: use sort_key_method instead.
+
+ - sort_key_method parameter is passed to list.sort as key parameter
if it + is not None. This allows to sort the list of predicates
found. The most important predicate is the first one in the list.
- ignored_category_list: this is the list of category that we do
@@ -203,8 +205,12 @@
# LOG('searchPredicateList, result_list before sort', 0,
result_list = filter_method(result_list)
- result_list.sort(sort_method)
+ result_list.sort(key=sort_key_method)
+ LOG('searchPredicateList', 0,
+ 'sort_method parameter is deprecated: sort_key_method
instead') + result_list.sort(cmp=sort_method)
# LOG('searchPredicateList, result_list after sort', 0, result_list)
return result_list
Modified: erp5/trunk/products/ERP5/tests/testDomainTool.py
http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testDomainTool.py?rev=26
242&r1=26241&r2=26242&view=diff
===========================================================================
=== --- erp5/trunk/products/ERP5/tests/testDomainTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testDomainTool.py [utf8] Wed Apr 1
return -1
return 0
+ hasCellContent = getattr(x, 'hasCellContent', None)
+ return bool(hasCellContent and hasCellContent(base_id='path'))
+
get_transaction().commit()
self.tic()
domain_tool = self.getDomainTool()
@@ -384,16 +388,24 @@
'variation/%s/blue' %
self.resource.getRelativeUrl()]) mapped_value =
domain_tool.generateMappedValue(context,sort_method=sort_method)
self.assertEquals(mapped_value.getProperty('base_price'),45)
+ mapped_value =
domain_tool.generateMappedValue(context,sort_key_method=sort_key_method) +
self.assertEquals(mapped_value.getProperty('base_price'),45)
context = self.resource.asContext(
categories=['resource/%s' %
self.resource.getRelativeUrl(), 'variation/%s/red' %
self.resource.getRelativeUrl()]) mapped_value =
domain_tool.generateMappedValue(context,sort_method=sort_method) +
self.assertEquals(mapped_value.getProperty('base_price'),26)
+ mapped_value =
domain_tool.generateMappedValue(context,sort_key_method=sort_key_method)
self.assertEquals(mapped_value.getProperty('base_price'),26)
# Now check the price
self.assertEquals(self.resource.getPrice(context=self.resource.asContext(
categories=['resource/%s' % self.resource.getRelativeUrl(),
'variation/%s/blue' % self.resource.getRelativeUrl()]),
sort_method=sort_method),45)
+
self.assertEquals(self.resource.getPrice(context=self.resource.asContext( +
categories=['resource/%s' %
self.resource.getRelativeUrl(), + 'variation/%s/blue' %
self.resource.getRelativeUrl()]), +
sort_key_method=sort_key_method),45)
def test_06_SQLQueryDoesNotReturnTooManyPredicates(self, quiet=0,
run=run_all_test): if not run: return
_______________________________________________
Erp5-report mailing list
Erp5-report at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-report
Date: Wed Apr 1 17:01:12 2009
New Revision: 26242
URL: http://svn.erp5.org?rev=26242&view=rev
Deprecate sort_method parameter in DomainTool.searchPredicateList since cmp
parameter in sorting methods is slow and deprecated. Add new
sort_key_method parameter that is passed as key parameter to list.sort.
erp5/trunk/products/ERP5/Tool/DomainTool.py
erp5/trunk/products/ERP5/tests/testDomainTool.py
Modified: erp5/trunk/products/ERP5/Tool/DomainTool.py
http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/DomainTool.py?rev=26242&r
1=26241&r2=26242&view=diff
===========================================================================
=== --- erp5/trunk/products/ERP5/Tool/DomainTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/DomainTool.py [utf8] Wed Apr 1 17:01:12
ignored_category_list=None,
tested_base_category_list=None,
filter_method=None, acquired=1,
# XXX: about "strict" parameter: This is a transition parameter,
# allowing someone hitting a bug to revert to original behaviour
easily. # It is not a correct name, as pointed out by Jerome. But instead
"""
Search all predicates which corresponds to this particular
context.
-
- - The sort_method parameter allows to give a method which will be
- used in order to sort the list of predicates found. The most
+
+ - sort_method parameter is deprecated: use sort_key_method instead.
+
+ - sort_key_method parameter is passed to list.sort as key parameter
if it + is not None. This allows to sort the list of predicates
found. The most important predicate is the first one in the list.
- ignored_category_list: this is the list of category that we do
@@ -203,8 +205,12 @@
# LOG('searchPredicateList, result_list before sort', 0,
result_list = filter_method(result_list)
- result_list.sort(sort_method)
+ result_list.sort(key=sort_key_method)
+ LOG('searchPredicateList', 0,
+ 'sort_method parameter is deprecated: sort_key_method
instead') + result_list.sort(cmp=sort_method)
# LOG('searchPredicateList, result_list after sort', 0, result_list)
return result_list
Modified: erp5/trunk/products/ERP5/tests/testDomainTool.py
http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testDomainTool.py?rev=26
242&r1=26241&r2=26242&view=diff
===========================================================================
=== --- erp5/trunk/products/ERP5/tests/testDomainTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testDomainTool.py [utf8] Wed Apr 1
return -1
return 0
+ hasCellContent = getattr(x, 'hasCellContent', None)
+ return bool(hasCellContent and hasCellContent(base_id='path'))
+
get_transaction().commit()
self.tic()
domain_tool = self.getDomainTool()
@@ -384,16 +388,24 @@
'variation/%s/blue' %
self.resource.getRelativeUrl()]) mapped_value =
domain_tool.generateMappedValue(context,sort_method=sort_method)
self.assertEquals(mapped_value.getProperty('base_price'),45)
+ mapped_value =
domain_tool.generateMappedValue(context,sort_key_method=sort_key_method) +
self.assertEquals(mapped_value.getProperty('base_price'),45)
context = self.resource.asContext(
categories=['resource/%s' %
self.resource.getRelativeUrl(), 'variation/%s/red' %
self.resource.getRelativeUrl()]) mapped_value =
domain_tool.generateMappedValue(context,sort_method=sort_method) +
self.assertEquals(mapped_value.getProperty('base_price'),26)
+ mapped_value =
domain_tool.generateMappedValue(context,sort_key_method=sort_key_method)
self.assertEquals(mapped_value.getProperty('base_price'),26)
# Now check the price
self.assertEquals(self.resource.getPrice(context=self.resource.asContext(
categories=['resource/%s' % self.resource.getRelativeUrl(),
'variation/%s/blue' % self.resource.getRelativeUrl()]),
sort_method=sort_method),45)
+
self.assertEquals(self.resource.getPrice(context=self.resource.asContext( +
categories=['resource/%s' %
self.resource.getRelativeUrl(), + 'variation/%s/blue' %
self.resource.getRelativeUrl()]), +
sort_key_method=sort_key_method),45)
def test_06_SQLQueryDoesNotReturnTooManyPredicates(self, quiet=0,
run=run_all_test): if not run: return
_______________________________________________
Erp5-report mailing list
Erp5-report at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-report
--
Yoshinori Okuji, Nexedi KK President
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.co.jp/
ERP5: Full Featured High End Open Source ERP
http://www.erp5.com/
ERP5 Wiki: Developer Zone for ERP5 Community
http://www.erp5.org/
Yoshinori Okuji, Nexedi KK President
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.co.jp/
ERP5: Full Featured High End Open Source ERP
http://www.erp5.com/
ERP5 Wiki: Developer Zone for ERP5 Community
http://www.erp5.org/