1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 00:00:00 +00:00

Added cache to char2pinyin tag

This commit is contained in:
zhengxie
2012-11-27 15:01:26 +08:00
parent 81417a0bc2
commit 47515f49e5

View File

@@ -206,7 +206,13 @@ cc.spliter = ''
@register.filter(name='char2pinyin')
def char2pinyin(value):
"""Convert Chinese character to pinyin."""
return cc.convert(value)
py = cache.get('CHAR2PINYIN_'+value)
if not py:
py = cc.convert(value)
cache.set('CHAR2PINYIN_'+value, py, 365 * 24 * 60 * 60)
return py
@register.filter(name='translate_permission')
def translate_permission(value):