aboutsummaryrefslogtreecommitdiff
path: root/sgdfi/objects/object.py
diff options
context:
space:
mode:
Diffstat (limited to 'sgdfi/objects/object.py')
-rw-r--r--sgdfi/objects/object.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/sgdfi/objects/object.py b/sgdfi/objects/object.py
index 602748a..a20f7e5 100644
--- a/sgdfi/objects/object.py
+++ b/sgdfi/objects/object.py
@@ -221,6 +221,8 @@ class ObjectProperty(Property):
def value(self, value = None):
if value is None:
+ if self._types:
+ return next(iter(self._types))()
return None
if all(not isinstance(value, cls) for cls in self._types):
raise TypeError("expected an instance of one of: "
@@ -242,7 +244,7 @@ class DataProperty(Property):
def value(self, value = None):
if value is None:
return None
- return type(self)._cls(value)
+ return type(self).cls(value)
class ArrayProperty(Property):
@@ -262,6 +264,8 @@ class ArrayProperty(Property):
for element in value:
array.append(element)
+ return array
+
class EnumProperty(Property):
""" Une propriété contenant une valeur d'une énumération. """
@@ -337,7 +341,7 @@ class _ObjectType(type):
fget = lambda self: getattr(self, f"_{key}")
fset = (lambda self, value: setattr(self, f"_{key}",
- prop.value(value) if value is not None else None))
+ prop.value(value)))
fdel = lambda self: setattr(self, f"_{key}", prop.value(None))
try: