[Erp5-report] r11633 - /erp5/trunk/products/ERP5Type/Utils.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Dec 7 11:57:25 CET 2006
Author: vincent
Date: Thu Dec 7 11:57:23 2006
New Revision: 11633
URL: http://svn.erp5.org?rev=11633&view=rev
Log:
Cache convertToUppercase result.
Modified:
erp5/trunk/products/ERP5Type/Utils.py
Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=11633&r1=11632&r2=11633&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py (original)
+++ erp5/trunk/products/ERP5Type/Utils.py Thu Dec 7 11:57:23 2006
@@ -138,14 +138,19 @@
# Useful methods
#####################################################
+_cached_convertToUpperCase = {}
def convertToUpperCase(key):
"""
This function turns an attribute name into
a method name according to the ERP5 naming conventions
"""
- if not isinstance(key, basestring):
- raise TypeError, '%s is not a string' % (key,)
- return ''.join([part.capitalize() for part in str(key).split('_')])
+ try:
+ return _cached_convertToUpperCase[key]
+ except KeyError:
+ if not isinstance(key, basestring):
+ raise TypeError, '%s is not a string' % (key,)
+ _cached_convertToUpperCase[key] = ''.join([part.capitalize() for part in key.split('_')])
+ return _cached_convertToUpperCase[key]
UpperCase = convertToUpperCase
More information about the Erp5-report
mailing list