Commit 6660e4c5 authored by Vincent Pelletier's avatar Vincent Pelletier

Cache convertToUppercase result.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11633 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9555803a
...@@ -138,14 +138,19 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw): ...@@ -138,14 +138,19 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw):
# Useful methods # Useful methods
##################################################### #####################################################
_cached_convertToUpperCase = {}
def convertToUpperCase(key): def convertToUpperCase(key):
""" """
This function turns an attribute name into This function turns an attribute name into
a method name according to the ERP5 naming conventions a method name according to the ERP5 naming conventions
""" """
try:
return _cached_convertToUpperCase[key]
except KeyError:
if not isinstance(key, basestring): if not isinstance(key, basestring):
raise TypeError, '%s is not a string' % (key,) raise TypeError, '%s is not a string' % (key,)
return ''.join([part.capitalize() for part in str(key).split('_')]) _cached_convertToUpperCase[key] = ''.join([part.capitalize() for part in key.split('_')])
return _cached_convertToUpperCase[key]
UpperCase = convertToUpperCase UpperCase = convertToUpperCase
......
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