Tom,
just tried this, works for me (notice there is no #!/usr/bin/env
python at the beginning of the file). If this and the last trivial
snippet I sent does not work, I would suspect some hickups in the
setup and installation of JPype and the Neo4j bindings?

I did (on Mac OS X, Python 2.6)

1. download http://sourceforge.net/projects/jpype/files/
2. unzip and run "python setup.py build && python setup.py install"
3. svn export https://svn.neo4j.org/components/neo4j.py/trunk neo4j-python
4. cd neo4j-python && sudo python setup.py install
5. run the above script with "python test.py"


Cheers,

/peter neubauer

COO and Sales, Neo Technology

GTalk:      neubauer.peter
Skype       peter.neubauer
Phone       +46 704 106975
LinkedIn   http://www.linkedin.com/in/neubauer
Twitter      http://twitter.com/peterneubauer

http://www.neo4j.org               - Your high performance graph database.
http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.



On Tue, Jul 27, 2010 at 6:39 PM, Tom Smith <[email protected]> wrote:
> This doesn't work (from the tutorial page)... any ideas where I'm going 
> wrong? Thanks...
>
> import neo4j
> from neo4j.util import Subreference
> graphdb = neo4j.GraphDatabase( "test_neo4j_db" )
>
> class SubCategoryProducts(neo4j.Traversal):
>  types = [neo4j.Outgoing.SUBCATEGORY, neo4j.Outgoing.PRODUCT]
>  def isReturnable(self, pos):
>      if pos.is_start: return False
>      return pos.last_relationship.type == 'PRODUCT'
>
> def attributes(product_node):
>  for category in categories(product_node):
>      for attr in category.ATTRIBUTE:
>          yield attr
>
> class categories(neo4j.Traversal):
>  types = [neo4j.Incoming.PRODUCT, neo4j.Incoming.SUBCATEGORY]
>  def isReturnable(self, pos):
>      return not pos.is_start
>
> with graphdb.transaction:
>        attribute_subref_node = Subreference.Node.ATTRIBUTE_ROOT(graphdb)
>        #attribute_subref_node.ATTRIBUTE_TYPE("Price") #Fails, do I need to 
> pass an object?
>        #attribute_subref_node.ATTRIBUTE_TYPE("Length")
>        #attribute_subref_node.ATTRIBUTE_TYPE("Name")
>
>        category_subref_node = Subreference.Node.CATEGORY_ROOT(graphdb, 
> Name="Products")
>        computers_node = graphdb.node(Name="Computers")
>
>        #create some categories
>        electronics_node = graphdb.node(Name="Laptops")
>        electronics_node.SUBCATEGORY(computers_node)
>
>        netbooks_node = graphdb.node(Name="Netbooks")
>        netbooks_node.SUBCATEGORY(computers_node)
>
>        desktops_node = graphdb.node(Name="Netbooks")
>        desktops_node.SUBCATEGORY(computers_node)
>
>        #create some products
>        little_dell = graphdb.node(Name="Little Dell", Colour="red", Price=210)
>        little_dell.is_a( netbooks_node )
>        print little_dell.id
>
>        little_acer = graphdb.node(Name="Little Acer", Colour="grey")
>        little_acer.is_a( netbooks_node )
>        print little_acer.id
>
>        little_eee = graphdb.node(Name="Little EEE", Colour="white", Price=200 
> )
>        little_eee.is_a( netbooks_node )
>        print little_eee.id
>
>        for rel in computers_node.SUBCATEGORY.outgoing:
>                print rel.end['Name']
>
>        for prod in SubCategoryProducts(computers_node):
>                print prod['Name']
>
>                for attr in attributes(prod):
>                        print attr['Name'], " of type ", attr.end['Name']
>                print
>
> graphdb.shutdown()
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to