Add long dotted syntax to "i18n:" TALES expression
authorThierry Florac <thierry.florac@onf.fr>
Wed, 21 Jun 2017 16:23:21 +0200
changeset 30 e82b56583f65
parent 29 1bf2c520ec6a
child 31 65e4710b699f
Add long dotted syntax to "i18n:" TALES expression
src/pyams_i18n/expr.py
--- a/src/pyams_i18n/expr.py	Tue Jun 06 17:00:23 2017 +0200
+++ b/src/pyams_i18n/expr.py	Wed Jun 21 16:23:21 2017 +0200
@@ -29,11 +29,15 @@
 
     name = name.strip()
     if '.' in name:
-        context_name, attr = name.split('.')
+        names = name.split('.')
+        context = econtext.get(names[0])
+        for name in names[1:-1]:
+            context = getattr(context, name)
+        attr = names[-1]
     else:
         context_name = 'context',
+        context = econtext.get(context_name)
         attr = name
-    context = econtext.get(context_name)
     request = econtext.get('request')
     return II18n(context).query_attribute(attr, request=request)