Commit 0546a66f authored by davebshow's avatar davebshow
Browse files

val is no longer a VertexProperty kwarg, is now just set behind the scenes

parent 97be0ac9
......@@ -60,10 +60,13 @@ class DataType(abc.ABC):
val = list(val)
else:
val = [val]
vertex_props = []
for v in val:
vp = vertex_prop(data_type, card=card)
vp.value = self.validate(v)
vertex_props.append(vp)
val = manager.ListVertexPropertyManager(
data_type, vertex_prop, card,
[vertex_prop(data_type, val=self.validate(v), card=card)
for v in val])
data_type, vertex_prop, card, vertex_props)
elif card == cardinality.Cardinality.set:
if isinstance(val, set):
val = val
......@@ -71,12 +74,17 @@ class DataType(abc.ABC):
val = set(val)
else:
val = set([val])
vertex_props = set([])
for v in val:
vp = vertex_prop(data_type, card=card)
vp.value = self.validate(v)
vertex_props.add(vp)
val = manager.SetVertexPropertyManager(
data_type, vertex_prop, card,
{vertex_prop(data_type, val=self.validate(v), card=card)
for v in val})
data_type, vertex_prop, card, vertex_props)
else:
val = vertex_prop(data_type, val=self.validate(val))
vp = vertex_prop(data_type)
vp.value = self.validate(val)
val = vp
return val
......
......@@ -154,12 +154,11 @@ class VertexProperty(Vertex, abc.BaseProperty):
__descriptor__ = VertexPropertyDescriptor
def __init__(self, data_type, *, val=None, default=None, db_name=None,
def __init__(self, data_type, *, default=None, db_name=None,
card=None):
if isinstance(data_type, type):
data_type = data_type()
self._data_type = data_type
self._val = val
self._default = default
self._db_name = db_name
if card is None:
......@@ -174,10 +173,14 @@ class VertexProperty(Vertex, abc.BaseProperty):
def data_type(self):
return self._data_type
@property
def value(self):
def getvalue(self):
return self._val
def setvalue(self, val):
self._val = val
value = property(getvalue, setvalue)
@property
def db_name(self):
return self._db_name
......
......@@ -49,9 +49,9 @@ class ListVertexPropertyManager(list, VertexPropertyManager):
list.__init__(self, obj)
def append(self, val):
val = self._data_type.validate(val)
val = self._vertex_prop(self._data_type, val=val, card=self._card)
super().append(val)
vp = self._vertex_prop(self._data_type, card=self._card)
vp.value = self._data_type.validate(val)
super().append(vp)
class SetVertexPropertyManager(set, VertexPropertyManager):
......@@ -61,6 +61,6 @@ class SetVertexPropertyManager(set, VertexPropertyManager):
set.__init__(self, obj)
def add(self, val):
val = self._data_type.validate(val)
val = self._vertex_prop(self._data_type, val=val, card=self._card)
super().add(val)
vp = self._vertex_prop(self._data_type, card=self._card)
vp.value = self._data_type.validate(val)
super().add(vp)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment