Skip to content

@espeed /bulbs03_example.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Bulbs 0.3 Neo4j Server Example
from bulbs.config import Config
from bulbs.gremlin import Gremlin
from bulbs.model import Node, NodeProxy
from bulbs.property import String, Integer
from bulbs.element import Vertex, VertexProxy, EdgeProxy, Edge
from bulbs.neo4jserver import Neo4jResource, NEO4J_URI, \
VertexIndexProxy, EdgeIndexProxy, ExactIndex
class Person(Node):
element_type = "person"
name = String(nullable=False)
age = Integer()
class Whybase(object):
def __init__(self):
self.config = Config(NEO4J_URI)
self.resource = Neo4jResource(self.config)
self.gremlin = Gremlin(self.resource)
self.indicesV = VertexIndexProxy(ExactIndex,self.resource)
self.indicesE = EdgeIndexProxy(ExactIndex,self.resource)
self.vertices = VertexProxy(Vertex,self.resource)
self.vertices.index = self.indicesV.get_or_create("vertices")
self.edges = EdgeProxy(Edge,self.resource)
self.edges.index = self.indicesE.get_or_create("edges")
self.people = NodeProxy(Person,self.resource)
self.people.index = self.indicesV.get_or_create("person")
whybase = Whybase()
james = whybase.people.create(name="James Thornton",age=34)
print james.eid, james.name, james.age
james.name = "James William Thornton"
james.city = "Dallas"
james.save()
print james.eid, james.name, james.age, james.city
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.