Created
January 20, 2012 21:31
-
-
Save espeed/1649714 to your computer and use it in GitHub Desktop.
Bulbs 0.3 Neo4j Server Example
This file contains 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 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