Hi Peter, If you scan farther down in the neo4j.py documentation at http://components.neo4j.org/neo4j.py/ in the Traversal section, there is the following. stop Definition of when the traversal should stop. Valid values are STOP_AT_DEPTH_ONE and STOP_AT_END_OF_GRAPH Alternatively the traversal class may define a more advanced stop predicate in the form of a method called 'isStopNode'.which suggests STOP_AT_DEPTH_ONE is appropriate. I'll try the approach you suggested.
Thanks! Chris Message: 2 > Date: Thu, 11 Nov 2010 01:18:38 +0100 > From: Peter Neubauer <peter.neuba...@neotechnology.com> > Subject: Re: [Neo4j] neo4j: STOP_AT_DEPTH_ONE undefined > To: Neo4j user discussions <user@lists.neo4j.org> > Message-ID: > <aanlktinku9ta2mpftuiwoyz_bxm33uhawt4cs=qmj...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Chris, > looking at the docs over at http://components.neo4j.org/neo4j.py/, it > seems you would do something like StopAtDepth(1) . > > Have not tested it, but indeed, there is no STOP_AT_DEPTH_ONE anywhere > in the source code ... > > Does that work better? > > Cheers, > > /peter neubauer > > 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 Wed, Nov 10, 2010 at 8:58 PM, Chris Diehl <di...@alumni.cmu.edu> wrote: > > Hi Peter, > > > > FYI, I just wrote a Python script to implement a simple traversal and got > > the following error when using STOP_AT_DEPTH_ONE as the stopping > criterion. > > > > Traceback (most recent call last): > > ?File "traversal_example.py", line 6, in <module> > > ? ?class SentMessages(neo4j.Traversal): > > ?File "traversal_example.py", line 9, in SentMessages > > ? ?stop = neo4j.STOP_AT_DEPTH_ONE > > AttributeError: 'module' object has no attribute 'STOP_AT_DEPTH_ONE' > > > > If I switch to STOP_AT_END_OF_GRAPH, all is well. > > > > Here's a representative code snippet. A slight variation on the example > > shown on the neo4j.py webpage. > > > > from __future__ import with_statement > > import neo4j > > > > class Hackers(neo4j.Traversal): > > ? ?types = [ > > ? ? ? ?neo4j.Outgoing.knows, > > ? ? ? ?neo4j.Outgoing.coded_by, > > ? ? ? ?] > > ? ?order = neo4j.DEPTH_FIRST > > ? ?stop = neo4j.STOP_AT_DEPTH_ONE > > > > ? ?def isReturnable(self, position): > > ? ? ? ?return (not position.is_start > > ? ? ? ? ? ? ? ?and position.last_relationship.type == 'coded_by') > > > > Chris > > _______________________________________________ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > > > ------------------------------ > > Message: 3 > Date: Wed, 10 Nov 2010 19:52:23 -0500 > From: "Wilson, Kalin" <kwil...@scitor.com> > Subject: [Neo4j] Using EmbeddedGraphDatabase in Tomcat > To: <user@lists.neo4j.org> > Message-ID: <ecb5d503c39b074f8b15110d710a4e2a7fd...@mail.scitor.com> > Content-Type: text/plain; charset="us-ascii" > > I am trying to learn Neo4J and prototype a simple web app using a simple > servlet/JSP approach (no Spring or other framework) in Tomcat. > > I have an instance of EmbeddedGraphDatabase that gets stored in a > ThreadLocal variable for use by other classes in a Singleton manner. > > This singleton variable gets initialized in a ServletContextListener and > shutdown() gets called in the listener's contextDestroyed() method. > > > > The first time the app is started the database is initialized properly > and everything seems OK. However, if I make code changes in a debugging > session and the changed files get hot deployed, subsequent database > accesses result in a lock exception. To recover I have to kill tomcat > and delete the database files. It doesn't seem that I'm calling > shutdown() at the right time to protect the database. > > > > I'm assuming that database access should be through some sort of > singleton, is this correct? I'm used to using a JPA EntityManager. > > > > Assuming I can't use Spring injection, etc, what is the recommended > pattern for managing the GraphDatabaseService instance in a web app? > > > > Any help is appreciated. > > Kalin > > > > ------------------------------ > > Message: 4 > Date: Thu, 11 Nov 2010 01:13:26 -0200 > From: Victor Augusto de Campos <piv...@gmail.com> > Subject: Re: [Neo4j] Using EmbeddedGraphDatabase in Tomcat > To: Neo4j user discussions <user@lists.neo4j.org> > Message-ID: > <aanlktimvnkj2hdzax-n1wmswdk8eesg--sxuuotaj...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Kalin, > I'm developing in a pretty similar case, except for that I'm not using > Spring and trying to not use the JEE stack at all (obviously the only > exception being Servlets :P). > > I do use a singleton and start in a static manner (not at > contextInitialized()) and added a shutdown() into contextDestroyed() and > it's all working fine, even hot deploying and etc, I've never experienced > it > to maintain a lock. > > I'd suggest you to try that approach and see if it works (and of course, to > give a feedback to any trouble you run into), it's working pretty well for > me, except for some times when Tomcat complains that the application > started > a thread and didn't killed it when redeployed but I didn't have time yet to > check that :/ > > I'd appreciate if anyone can give me a feedback over this approach too, > thanks all :D > > Best regards, > Victor > > @victorcampos on twitter > > > On Wed, Nov 10, 2010 at 10:52 PM, Wilson, Kalin <kwil...@scitor.com> > wrote: > > > I am trying to learn Neo4J and prototype a simple web app using a simple > > servlet/JSP approach (no Spring or other framework) in Tomcat. > > > > I have an instance of EmbeddedGraphDatabase that gets stored in a > > ThreadLocal variable for use by other classes in a Singleton manner. > > > > This singleton variable gets initialized in a ServletContextListener and > > shutdown() gets called in the listener's contextDestroyed() method. > > > > > > > > The first time the app is started the database is initialized properly > > and everything seems OK. However, if I make code changes in a debugging > > session and the changed files get hot deployed, subsequent database > > accesses result in a lock exception. To recover I have to kill tomcat > > and delete the database files. It doesn't seem that I'm calling > > shutdown() at the right time to protect the database. > > > > > > > > I'm assuming that database access should be through some sort of > > singleton, is this correct? I'm used to using a JPA EntityManager. > > > > > > > > Assuming I can't use Spring injection, etc, what is the recommended > > pattern for managing the GraphDatabaseService instance in a web app? > > > > > > > > Any help is appreciated. > > > > Kalin > > > > _______________________________________________ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > > > ------------------------------ > > Message: 5 > Date: Thu, 11 Nov 2010 11:18:19 +0000 > From: Stephane Urdy <stephane.u...@googlemail.com> > Subject: Re: [Neo4j] Using EmbeddedGraphDatabase in Tomcat > To: Neo4j user discussions <user@lists.neo4j.org> > Message-ID: <4cdbd0fb.7030...@googlemail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Wilson, Kalin wrote: > > I am trying to learn Neo4J and prototype a simple web app using a simple > > servlet/JSP approach (no Spring or other framework) in Tomcat. > > > > I have an instance of EmbeddedGraphDatabase that gets stored in a > > ThreadLocal variable for use by other classes in a Singleton manner. > > > > This singleton variable gets initialized in a ServletContextListener and > > shutdown() gets called in the listener's contextDestroyed() method. > > > > > > > > The first time the app is started the database is initialized properly > > and everything seems OK. However, if I make code changes in a debugging > > session and the changed files get hot deployed, subsequent database > > accesses result in a lock exception. To recover I have to kill tomcat > > and delete the database files. It doesn't seem that I'm calling > > shutdown() at the right time to protect the database. > > > > > > > > I'm assuming that database access should be through some sort of > > singleton, is this correct? I'm used to using a JPA EntityManager. > > > > > > > > Assuming I can't use Spring injection, etc, what is the recommended > > pattern for managing the GraphDatabaseService instance in a web app? > > > > > > > > Any help is appreciated. > > > > Kalin > > > > _______________________________________________ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > > > Hi Kalin, > > You could use the graphdatabase service [add-on to the standard neo4j > package] to start/stop your graph db. > You can extend httpservlet and > - start your graph db with the graphdatabase service on the init() > method > - stop your graph db with the graphdatabase service on the destroy() > method > > When you start tomcat or start your web application via tomcat manager, > the init() method will be called and will gracefully start your graph db. > When you stop tomcat or stop your web application via tomcat manager, > the destroy() method will be called and will gracefully stop your graph db. > > It works perfectly for me :) > > Cheers, > > Stephane Urdy > > > > ------------------------------ > > _______________________________________________ > User mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > > > End of User Digest, Vol 44, Issue 23 > ************************************ > _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user