Skip to content

Instantly share code, notes, and snippets.

@espeed
Created November 14, 2011 09:35
Show Gist options
  • Save espeed/1363608 to your computer and use it in GitHub Desktop.
Save espeed/1363608 to your computer and use it in GitHub Desktop.
Example Bulbs 0.3 Domain Object
from bulbs.graph import Graph
from bulbs.config import Config
from bulbs.element import Vertex, Edge
from bulbs.proxy import VertexProxy, EdgeProxy, IndexProxy
from bulbs.model import Node, NodeProxy
from bulbs.gremlin import Gremlin
# Bulbs 0.3 has pluggable resources -- there is a Neo4j Server Resource as well
from bulbs.resources import RexsterResource, RexsterIndex
# Your Domain Models
from whybase.idea import Idea
class Whybase(Graph):
def __init__(self):
self.config = Config("http://localhost:8182/graphs/test")
self.resource = RexsterResource(self.config)
self.gremlin = Gremlin(self.resource)
self.indices = IndexProxy(self.resource,RexsterIndex)
self.vertices = VertexProxy(self.resource,Vertex)
self.vertices.index = self.indices.get_and_register("vertices")
self.edges = EdgeProxy(self.resource,Edge)
self.edges.index = self.indices.get_and_register("edges")
self.ideas = NodeProxy(self.resource,Idea)
self.ideas.index = self.indices.get_and_register("ideas")
whybase = Whybase()
idea = whybase.ideas.create(text="The key to life is perspective.")
print idea.eid, idea.element_type, idea.text, idea.stub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment