symlink support

This commit is contained in:
Emmanuel Garette 2019-01-18 14:15:05 +01:00
parent 36936edbe1
commit 140fa03592
1 changed files with 19 additions and 8 deletions

View File

@ -36,10 +36,12 @@ class TiramisuOptionOption:
def __init__(self,
path: str,
schema: Dict,
model: Dict) -> None:
model: Dict,
form: Dict) -> None:
self._path = path
self.schema = schema
self.model = model
self.form = form
def doc(self):
return self.schema['title']
@ -47,8 +49,15 @@ class TiramisuOptionOption:
def path(self):
return self._path
def name(self):
return self._path.rsplit('.', 1)[-1]
def name(self,
follow_symlink: bool=False) -> str:
if not follow_symlink or \
self.isoptiondescription() or \
not self.issymlinkoption():
path = self._path
else:
path = self.schema['opt_path']
return path.rsplit('.', 1)[-1]
def isoptiondescription(self):
return self.schema['type'] in ['object', 'array']
@ -57,8 +66,7 @@ class TiramisuOptionOption:
return self.schema['type'] == 'array'
def issymlinkoption(self) -> bool:
# FIXME
return False
return self.schema['type'] == 'symlink'
def ismulti(self) -> bool:
return self.schema.get('isMulti', False)
@ -76,7 +84,8 @@ class TiramisuOptionOption:
'domain': 'domainname',
'url': 'url',
'username': 'username',
'string': 'str'}
'string': 'str',
'symlink': 'symlink'}
if self.schema['type'] in types :
return types[self.schema['type']]
raise Exception('unsupported type {}'.format(self.schema['type']))
@ -313,7 +322,8 @@ class TiramisuOptionDescription(_Option):
if subfunc == 'option':
return TiramisuOptionOption(self.path,
self.schema,
self.model)
self.model,
self.form)
if subfunc == 'property':
return TiramisuOptionProperty(self.model.get(self.path, {}))
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
@ -353,7 +363,8 @@ class TiramisuOption:
raise NotImplementedError()
return TiramisuOptionOption(self.path,
self.schema,
self.model)
self.model,
self.form)
if subfunc == 'value':
return TiramisuOptionValue(self.config,
self.schema,