Created
November 14, 2011 09:35
-
-
Save espeed/1363608 to your computer and use it in GitHub Desktop.
Example Bulbs 0.3 Domain Object
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.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