mgmt: encode property type in property.Get
This also require having property.type public. QubesOS/qubes-issues#2622
This commit is contained in:
parent
3b36e92b6d
commit
dbf2066dfd
@ -193,7 +193,7 @@ class property(object): # pylint: disable=redefined-builtin,invalid-name
|
|||||||
self._setter = setter
|
self._setter = setter
|
||||||
self._saver = saver if saver is not None else (
|
self._saver = saver if saver is not None else (
|
||||||
lambda self, prop, value: str(value))
|
lambda self, prop, value: str(value))
|
||||||
self._type = type
|
self.type = type
|
||||||
self._default = default
|
self._default = default
|
||||||
self._write_once = write_once
|
self._write_once = write_once
|
||||||
self.order = order
|
self.order = order
|
||||||
@ -245,8 +245,8 @@ class property(object): # pylint: disable=redefined-builtin,invalid-name
|
|||||||
|
|
||||||
if self._setter is not None:
|
if self._setter is not None:
|
||||||
value = self._setter(instance, self, value)
|
value = self._setter(instance, self, value)
|
||||||
if self._type not in (None, type(value)):
|
if self.type not in (None, type(value)):
|
||||||
value = self._type(value)
|
value = self.type(value)
|
||||||
|
|
||||||
if has_oldvalue:
|
if has_oldvalue:
|
||||||
instance.fire_event_pre('property-pre-set:' + self.__name__,
|
instance.fire_event_pre('property-pre-set:' + self.__name__,
|
||||||
|
@ -165,14 +165,28 @@ class QubesMgmt(object):
|
|||||||
|
|
||||||
self.fire_event_for_permission()
|
self.fire_event_for_permission()
|
||||||
|
|
||||||
|
property_def = self.dest.property_get_def(self.arg)
|
||||||
|
# explicit list to be sure that it matches protocol spec
|
||||||
|
if isinstance(property_def, qubes.vm.VMProperty):
|
||||||
|
property_type = 'vm'
|
||||||
|
elif property_def.type is int:
|
||||||
|
property_type = 'int'
|
||||||
|
elif property_def.type is bool:
|
||||||
|
property_type = 'bool'
|
||||||
|
elif self.arg == 'label':
|
||||||
|
property_type = 'label'
|
||||||
|
else:
|
||||||
|
property_type = 'str'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
value = getattr(self.dest, self.arg)
|
value = getattr(self.dest, self.arg)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return 'default=True '
|
return 'default=True type={} '.format(property_type)
|
||||||
else:
|
else:
|
||||||
return 'default={} {}'.format(
|
return 'default={} type={} {}'.format(
|
||||||
str(self.dest.property_is_default(self.arg)),
|
str(self.dest.property_is_default(self.arg)),
|
||||||
self.repr(value))
|
property_type,
|
||||||
|
str(value) if value is not None else '')
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def vm_property_help(self, untrusted_payload):
|
def vm_property_help(self, untrusted_payload):
|
||||||
|
Loading…
Reference in New Issue
Block a user