summaryrefslogtreecommitdiff
path: root/src/leap/base/pluggableconfig.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-12-21 10:28:46 +0900
committerkali <kali@leap.se>2012-12-21 10:28:46 +0900
commitec0fc05e3918782dbb29f9f6901c0de22419134d (patch)
treee5e49bc7601e08cc604b54c1388c0fd0241f980b /src/leap/base/pluggableconfig.py
parentea4a3b3396caeeaa2be4dc46aecf386a56a522c9 (diff)
magic translatable objects
Diffstat (limited to 'src/leap/base/pluggableconfig.py')
-rw-r--r--src/leap/base/pluggableconfig.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/leap/base/pluggableconfig.py b/src/leap/base/pluggableconfig.py
index 0ca985ea..3517db6b 100644
--- a/src/leap/base/pluggableconfig.py
+++ b/src/leap/base/pluggableconfig.py
@@ -10,6 +10,8 @@ import urlparse
import jsonschema
+from leap.util.translations import LEAPTranslatable
+
logger = logging.getLogger(__name__)
@@ -118,7 +120,6 @@ adaptors['json'] = JSONAdaptor()
# to proper python types.
# TODO:
-# - multilingual object.
# - HTTPS uri
@@ -132,6 +133,20 @@ class DateType(object):
return time.strftime(self.fmt, data)
+class TranslatableType(object):
+ """
+ a type that casts to LEAPTranslatable objects.
+ Used for labels we get from providers and stuff.
+ """
+
+ def to_python(self, data):
+ return LEAPTranslatable(data)
+
+ # needed? we already have an extended dict...
+ #def get_prep_value(self, data):
+ #return dict(data)
+
+
class URIType(object):
def to_python(self, data):
@@ -164,6 +179,7 @@ types = {
'date': DateType(),
'uri': URIType(),
'https-uri': HTTPSURIType(),
+ 'translatable': TranslatableType(),
}