Permalink
Browse files

fixing setup.py and finishing markup

  • Loading branch information...
1 parent cef928c commit 43af2fa56c5688a80f827858507a4376a6cb9e85 @turtlebender turtlebender committed Apr 27, 2012
Showing with 36 additions and 23 deletions.
  1. +24 −22 README.md
  2. +11 −0 requirements.txt
  3. +1 −1 setup.py
View
@@ -40,91 +40,93 @@ Now we will retrieve the spiderpig from the graph and check that the attributes
Now we will create a friend for the spiderpig (who also happens to be his alter ego). Again, let's check to
confirm that the node and it's attributes were created correctly.
-
+```python
>>> harry_plopper = graph_db.create_node('test_type', 'Harry Plopper', {'sound':'plop'})
>>> harry_plopper = graph_db.get_node('test_type','Harry Plopper')
>>> harry_plopper['sound']
'plop'
+```
Nodes can have different types as well. Here we create a node of type simpson, with name Homer. This node has
different attributes than the previous nodes.
+```python
>>> homer = graph_db.create_node('simpson', 'Homer', {'sound':'Doh', 'job':'Safety Inspector'})
>>> homer = graph_db.get_node('simpson', 'Homer')
>>> homer['sound']
'Doh'
>>> homer['job']
'Safety Inspector'
-
+```
Nodes by themselves are not very useful. Let's create a relationship between spiderpig and Harry Plopper.
-
+```python
>>> rel = spiderpig.friend(harry_plopper, key='spiderpig_harry_plopper_alliance', alter_ego=True, best=False)
-
+```
This creates a relationship of type friend. The key has been specified in this case, although it is not necessary.
If no key is supplied a uuid will be generated for the relationship.
Every node type has a "reference node". This is a metanode for the type and functions as an index for all nodes of a
given type.
-
+```python
>>> reference_node = graph_db.get_reference_node('test_type')
-
+```
Getting the instances from the test_type reference node should return the Harry Plopper node and the spiderpig node.
-
+```python
>>> sorted([rel.target_node.key for rel in reference_node.instance.outgoing])
['Harry Plopper', 'spiderpig']
-
+```
The spiderpig should only have one friend at this point, and it should be Harry Plopper
-
+```python
>>> friends = [rel for rel in spiderpig.friend]
>>> len(friends)
1
>>> friends[0].target_node.key
'Harry Plopper'
-
+```
Now let's confirm that Harry Plopper is friends with spider pig as well:
-
+```python
>>> 'spiderpig' in harry_plopper.friend
True
-
+```
And, once more, make sure that spider pig is Harry Plopper's only friend:
-
+```python
>>> friends = [rel for rel in harry_plopper.friend]
>>> len(friends)
1
>>> friends[0].source_node.key
'spiderpig'
-
+```
They should not be best friends. Let's confirm this:
-
+```python
>>> friends[0]['best']
False
-
+```
Homer is spiderpig's best friend:
-
+```python
>>> rel = homer.friend(spiderpig, best=True, alter_ego=False, type='love', strength=100)
-
+```
Here we added additional attributes to the relationship.
Now spiderpig should have 2 friends.
-
+```python
>>> friends = [rel for rel in spiderpig.friend]
>>> len(friends)
2
-
+```
You can get a list of all of the relationships of a particular type between a node and other nodes with a particular key
-
+```python
>>> homer_spiderpig_love = spiderpig.friend.relationships_with('Homer')
>>> len(homer_spiderpig_love)
1
>>> homer_spiderpig_love = spiderpig.friend.relationships_with('Homer')
>>> print homer_spiderpig_love[0]['strength']
100
-
+```
Thanks To
View
@@ -0,0 +1,11 @@
+agamemnon==0.3.3.0
+isodate==0.4.7
+nose==1.1.2
+ordereddict==1.1
+pycassa==1.4.0
+pyparsing==1.5.6
+python-dateutil==1.5
+rdfextras==0.1
+rdflib==3.2.0
+thrift==0.8.0
+wsgiref==0.1.2
View
@@ -3,7 +3,7 @@
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
-README = open('README.rst').read()
+README = open('README.md').read()
CHANGES = open('CHANGES.txt').read()
requires = ['pycassa==1.4.0', 'thrift', 'pyes', 'setuptools','ordereddict','rdflib','rdfextras','python-dateutil==1.5', 'pyyaml']

0 comments on commit 43af2fa

Please sign in to comment.