Closed leifurhauks closed 8 years ago
This is nice @leifurhauks thanks. I was wondering though, maybe we could go simpler?
Instead of the RemoteVertex/Edge, something like:
element = collections.namedtuple(
"element",
['id', 'label', 'properties', 'obj'])
Then:
def _element_hook(obj):
obj_type = obj.get('type', None)
if obj_type in ['vertex', 'edge']:
id_ = obj.pop('id')
label = obj.pop('label')
properties = obj.pop('properties', dict())
obj = element(id_, label, properties, obj)
return obj
Just a thought. Let me know what you think.
New object hook for json deserializer detects elements and deserializes them as RemoteElements, either RemoteVertex or RemoteEdge.
The RemoteElement interface is (loosely) based on tinkerpop's Element interface.
For obvious reasons, RemoteElement should only have read-only methods and properties.
Marked WIP for now because:
1) no tests yet :c 2) only the driver part has been implemented, but changes would need to be made to goblin as well