Last active
July 7, 2016 15:11
-
-
Save davebshow/ac72b78e461dd9a63e7d453df0490c55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from goblin import api | |
from goblin import properties | |
class TestVertexProperty(api.VertexProperty): | |
notes = properties.Property(properties.String) | |
class TestVertex(api.Vertex): | |
__label__ = 'test_vertex' | |
name = TestVertexProperty(properties.String) | |
address = properties.Property(properties.String) | |
>>> t = TestVertex() | |
# Simple Property | |
>>> t.address | |
# None | |
>>> t.address = "123 Some Street, Montreal" | |
>>> t.address | |
# '123 Some Street, Montreal' | |
>>> type(t.address) | |
# str | |
# VertexProperty | |
>>> t.name | |
# None | |
>>> t.name = 'jon' | |
>>> t.name | |
# <TestVertexProperty(type=<goblin.properties.String object at 0x7f5468148780>, value=jon) | |
>>> type(t.name) | |
# __main__.TestVertexProperty | |
>>> t.name.value # gets the 'value' of the VertexProperty | |
# 'jon' | |
# VertexProperty properties are simple Property | |
>>> t.name.notes | |
# None | |
>>> t.name.notes = "jonathan's unofficial nickname" | |
>>> t.name.notes | |
# "jonathan's unofficial nickname" | |
>>> type(name.notes) | |
# str | |
# VertexProperty can have different vals with the same key | |
>>> t.name = ['leif', 'jon', 'dave'] | |
>>> t.name | |
# [<TestVertexProperty(type=<goblin.properties.String object at 0x7f5468148780>, value=leif), | |
# <TestVertexProperty(type=<goblin.properties.String object at 0x7f5468148780>, value=jon), | |
# <TestVertexProperty(type=<goblin.properties.String object at 0x7f5468148780>, value=dave)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment