diff --git a/data/calculate-core b/data/calculate-core index 0498ec9..ddcb7ce 100644 --- a/data/calculate-core +++ b/data/calculate-core @@ -1,4 +1,4 @@ -#!/sbin/runscript +#!/sbin/openrc-run # Copyright 2015-2016 Mir Calculate. http://www.calculate-linux.org # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/pym/core/server/api_types.py b/pym/core/server/api_types.py index 83cf0c9..567cba3 100644 --- a/pym/core/server/api_types.py +++ b/pym/core/server/api_types.py @@ -15,8 +15,10 @@ # limitations under the License. from calculate.core.server.loaded_methods import LoadedMethods -from soaplib.serializers.primitive import String, Integer, Boolean +from soaplib.serializers.primitive import String, Integer, Boolean, string_encoding from soaplib.serializers.clazz import Array, ClassSerializer +from soaplib.serializers import nillable_value, nillable_element +from soaplib.serializers import string_to_xml from soaplib.service import rpc import sys import pickle @@ -47,6 +49,23 @@ class CommonInfo(ClassSerializer): Default = Array(String) CheckAll = Boolean +class LazyString(object): + pass + +def lazyable(cl): + def to_xml(cls, value, tns, parent_elt, name='retval'): + if isinstance(value, LazyString): + value = str(value) + if not isinstance(value, unicode): + value = unicode(value, string_encoding) + + string_to_xml(cls, value, tns, parent_elt, name) + + cl.to_xml = classmethod(nillable_value(to_xml)) + return cl + +String = lazyable(String) + class DataVarsSerializer(ClassSerializer): """Serializer for datavars types""" @@ -73,7 +92,7 @@ class DataVarsSerializer(ClassSerializer): if type(value) in (list, tuple): return [""] + map(lambda x: (",".join(x) if type(x) in (list, tuple) - else str(x)), + else x), value) else: return value diff --git a/pym/core/set_vars.py b/pym/core/set_vars.py index 0808f42..6e22c7c 100644 --- a/pym/core/set_vars.py +++ b/pym/core/set_vars.py @@ -47,7 +47,7 @@ class Variables(MethodsInterface): section, op, varname = varname.rpartition('.') if not location: for env_location in dv.Get('main.cl_env_location'): - if not dv.Delete(varname, location, header=section): + if not dv.Delete(varname, env_location, header=section): self.printWARNING( _("Failed to delete variable {var} from " "{location}").format( diff --git a/pym/core/variables/variable.py b/pym/core/variables/variable.py index 7e92b18..86b1850 100644 --- a/pym/core/variables/variable.py +++ b/pym/core/variables/variable.py @@ -18,6 +18,7 @@ import re from os import path from calculate.lib.datavars import (Variable, ReadonlyVariable, VariableError, TableVariable) +from calculate.core.server.api_types import LazyString from calculate.lib.cl_lang import setLocalTranslate @@ -168,7 +169,7 @@ class VariableClVariableValue(VarHelper, Variable): """ type = "list" - class LazyVal: + class LazyVal(LazyString): """ Lazy value return string value only before using """