Add support SourceReadonlyVariables for disk_size

Add create help and label in breif data.
Add support lazy translate for methods names.
master3.3
parent ffa1f4f48b
commit 8b668495d1

@ -20,6 +20,7 @@ from soaplib.serializers.clazz import Array, ClassSerializer
from soaplib.service import rpc
import sys
from itertools import *
from calculate.lib.datavars import SourceReadonlyVariable
from calculate.lib.cl_lang import setLocalTranslate
setLocalTranslate('calculate_api',sys.modules[__name__])
@ -68,15 +69,24 @@ class ChoiceValue(DataVarsSerializer):
comments = Array(String)
onChanged = Array(String)
def __init__(self,dv=None,varObj=None,**kwargs):
def __init__(self,dv=None,varObj=None,readOnly=False,**kwargs):
if dv:
super(ChoiceValue,self).__init__()
self.values, self.comments = self.getChoice(varObj)
if not readOnly:
self.values, self.comments = self.getChoice(varObj)
elif isinstance(varObj,SourceReadonlyVariable):
self.values, self.comments = \
zip(*varObj.getMapHumanReadable().items())
self.values = self.arrayString(self.values)
self.comments = self.arrayString(self.comments)
if varObj.mode == 'w':
self.typefield = varObj.element or \
self.elementByType(varObj.type)
else:
self.typefield = "text"
if readOnly:
self.typefield = "readonly"
else:
self.typefield = "text"
else:
super(ChoiceValue,self).__init__(**kwargs)
@ -115,6 +125,8 @@ class Table(DataVarsSerializer):
self.values.append(ChoiceValue(dv,varSource))
if varSource.mode == 'r' and i == 0:
self.writable = False
else:
self.values.append(ChoiceValue(dv,varSource,readOnly=True))
# get table body
# empty value at start add for fix data transfer
self.body = self.arrayArrayString(dv.Get(varObj.name,
@ -282,7 +294,10 @@ class ViewInfo(DataVarsSerializer):
lastGroup = len(varGroups)-1
# interate all vars group
if step in(0,-1,None) or allsteps:
self.groups.append(self.stepGroup(varGroups,brief_label))
briefData = datavars.getBrief()
self.groups.append(self.stepGroup(varGroups,brief_label,
help_value=briefData.get("help",None),
next_value=briefData.get("next",None)))
for i, groupInfo in enumerate(varGroups):
if step in (None,-1) or step == i:
self.groups.append(GroupField(dv=datavars,info=groupInfo,
@ -291,13 +306,15 @@ class ViewInfo(DataVarsSerializer):
else:
self.groups = groups
def stepGroup(self,groupInfo,brief_label):
def stepGroup(self,groupInfo,brief_label,help_value=None,next_value=None):
"""Step group"""
return GroupField(fields=[
Field(name = "Steps",
element = "table",
label = brief_label,
type = 'steps',
help = help_value,
value = next_value,
tablevalue = Table(
head = [i['name'] for i in groupInfo],
body = [list(i['normal'])+[""]+list(i['expert'])

@ -328,7 +328,8 @@ class Basic (DefinitionBase) :
@rpc(String, _returns = Array(Array(String)))
def get_methods ( self, client_type) :
return self.serv_get_methods (client_type)
return map(lambda x:map(str,x),
self.serv_get_methods (client_type))
@rpc(_returns = Array(String))
@Dec.check_permissions(['get_sessions'])

@ -48,4 +48,4 @@ class Dec:
def wrapper(function):
cls.rightsMethods[function.__name__] = add_right
return function
return wrapper
return wrapper

@ -540,4 +540,4 @@ def _(s):
def uniq(seq):
seen = set()
seen_add = seen.add
return [ x for x in seq if x not in seen and not seen_add(x)]
return [ x for x in seq if x not in seen and not seen_add(x)]

Loading…
Cancel
Save