Re: [Neo4j] Lab day: Cypher queries in embedded python bindings

2011-12-02 Thread Johan Lundberg
On 2011-11-18 17:12, Jacob Hansson wrote:
 Hey all,
 
 Like we've mentioned before, we have lab-day fridays at Neo4j, and
 today I hacked some stuff together that landed directly in trunk
 for the embedded python bindings.
 
 As of 1 minute ago, the following operations are now possible with
 the embedded python API:
 
 from neo4j import GraphDatabase db =
 GraphDatabase(/home/jake/db)
 
 # Plain query result = db.query(START n=node(0) RETURN n)
 
 # Parameterized query result = db.query(START n=node({id}) RETURN
 n, id=0)
 
 # Pre-parsed query get_node_by_id = db.prepare_query(START
 n=node({id}) RETURN n) result = db.query(get_node_by_id, id=0)
 
 # Read the result for row in result: print row['n']
 
 for value in result['n']: print value
 
 node = db.query(get_node_by_id, id=0)['n'].single
 
 Lemme know what you think :)
 
 This is not available on Pypi yet (will be when the first 1.6
 milestone is released) but you can build it super-easily yourself,
 instructions are in the readme at github:
 https://github.com/neo4j/python-embedded
 

Hello Jake and you other pythonistas,

I have finally found time to test the Cypher queries in the Python
bindings and I just want to say thank you. Great addition for us!

Br
-- 
Johan Lundberg
NORDUnet A/S
lundb...@nordu.net
+46730714375
Tulegatan 11
113 53 Stockholm
Sweden
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Python embedding: problems with shutdown and threads

2011-11-03 Thread Johan Lundberg
On 2011-11-03 11:08, Jacob Hansson wrote:
 On Thu, Nov 3, 2011 at 6:55 AM, Tim McNamara 
 paperl...@timmcnamara.co.nzwrote:
 
 Here are a few notes of my own from using Neo4j with Python embedded.
 I know that this isn't the right place .

 Ubuntu doesn't set $JAVA_HOME. I ended up hard coding the location of my
 JVM.

 I seem to encounter unclean shutdowns all the time when running with
 the iPython REPL. Is there a db.shutdown() command that I've been
 neglecting to use?

 
 Yeah, as long as you call db.shutdown(), things should be ok. See here:
 
 http://docs.neo4j.org/chunked/snapshot/python-embedded-reference-core.html
 
 
 We should perhaps set up the db to shut itself down properly automatically
 if it detects that python is shutting down.. We decided against that
 before, since we felt like we don't own the application lifecycle. WDYT?


I found this snippet to work great for my modules:
def _close_db():
try:
neo4jdb.shutdown()
except NameError:
print 'Could not shutdown Neo4j database. Is it open in \
another process?'

import atexit
atexit.register(_close_db)

 

 Tim


 On 3 November 2011 17:28, Michael Rene Armida m...@marmida.com wrote:
 I'm having some weird problems with threading on shutdown.  As I
 previously
 discovered, using neo4j in a multi-threaded Python app requires complete
 segregation of neo4j into a single thread.  That all works fine for
 creating a database, however, it appears that shutting one down is a bit
 of
 a mystery.  I wrote a test program to minimally illustrate the
 difficulty:

 http://pastebin.com/gg204kae

 Threading is always easy to get wrong, so I added a simple switch to
 remove
 neo4j from the picture.  When I disable neo, the program starts up and
 shuts down cleanly.  When I re-enable neo, some of the print statements
 never get run, and the app mysteriously exits.

 I am testing this by saving it into a script and running it on the
 command
 line.  Any time after the worker thread finishes creating the neo db, I
 hit
 ctrl-c, and the two scenarios play out as above.

 It seems that the embedded Python API is not exactly at the forefront of
 popular use, and so I understand if nobody knows what's up with this.  I
 just thought I should add something, for the record.  I hope my script
 doesn't have an obvious bug.

 Thanks,
 Michael

 
 I had a discussion with Tobias this morning about threading with JPype, and
 am currently writing a fix that will allow full threading support for
 neo4j-embedded.
 
 I'll make sure to run this script as well after that fix is implemented, to
 make sure it gets fixed as well.
 
 As far as the forefront of use goes, there is a surprising amount of pypy
 downloads of neo4j-embedded (4000 new installs in the last 30 days), so the
 feedback you are providing here is gonna end up helping a lot of people :)
 Thank you so much for taking the time to document the issues you are having.
 
 /jake
 
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

 
 
 


-- 
Johan Lundberg
NORDUnet A/S
lundb...@nordu.net
+46730714375
Tulegatan 11
113 53 Stockholm
Sweden
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Problems binding to a specific ip

2011-06-14 Thread Johan Lundberg
Hello,

Are there any plans to address the access control problem? I think that
even when you can use iptables or similar to achieve the same end
result, it would be nice to be able to set a bind address in the neo4j
configuration.

Also https would be a nice feature :)

Br
Johan

On 2011-06-09 16.14, Chris Gioran wrote:
 Hi Max,
 
 there are two distinct problems here
 
 One is that there is no IP access control that can be configured
 through Neo4j. Setting the
 listen URIs to a specific address in the configuration does not bind
 the server there exclusively. This
 behavior has to be imposed with external means, such as a firewall.
 
 The other is a benign bug that has to do with logging the listen
 address - currently it uses always the
 java.net.InetAddress methods to find the hostname, ignoring the
 configuration and leading to the
 behavior you describe, since the JVM does not prefer the localhost
 interface. This will be of course
 addressed in subsequent SNAPSHOTs and milestone releases but it will
 remain the default behavior.
 
 Hope that clarifies things.
 
 cheers,
 CG
 
 On Wed, Jun 8, 2011 at 2:59 PM, Maximilian Schulz nam...@gmail.com wrote:
 Hi everyone,

 after weeks of experimentation, we finally migrated one of our apps features
 to neo4j. But now that we are about to deploy the app to our staging server,
 we discovered a small problem with the server configuration. We have checked
 the manual at
 http://docs.neo4j.org/chunked/1.4.M03/server-configuration.html and followed
 the suggested configuration, but we are not getting the expected results.

 What we are trying to achieve is to bind the server to localhost, so it is
 no longer accessible from outside. We restricted access to IPv4 in the
 wrapper config and set the webadmin data and manage uri to
 http://localhost:7474. But when starting the server it still binds to the
 hostname.

 Here is the output of the start process. Check the last line, where it
 states that the server is started on http://OUR_DOMAIN:7474/

 6/8/11 1:44:46 PM org.neo4j.server.database.Database INFO: Using database at
 /tmp/neo4j-community-1.4.M03/data/graph.db
 6/8/11 1:44:47 PM org.neo4j.server.modules.DiscoveryModule INFO: Mounted
 discovery module at [/]
 6/8/11 1:44:47 PM org.neo4j.server.modules.RESTApiModule INFO: Mounted REST
 API at [http://localhost:7474/db/data/]
 6/8/11 1:44:47 PM org.neo4j.server.modules.ManagementApiModule INFO: Mounted
 management API at [http://localhost:7474/db/manage/]
 6/8/11 1:44:47 PM org.neo4j.server.modules.WebAdminModule INFO: Mounted
 webadmin at [/webadmin]
 6/8/11 1:44:47 PM org.neo4j.server.NeoServerWithEmbeddedWebServer INFO:
 Starting Neo Server on port [7474]
 6/8/11 1:44:47 PM org.neo4j.server.web.Jetty6WebServer INFO: Mounting static
 content at [/webadmin] from [webadmin-html]
 6/8/11 1:44:48 PM org.neo4j.server.NeoServerWithEmbeddedWebServer INFO:
 Server started on [http://OUR_DOMAIN:7474/]


 I am pretty sure that I have missed something, but I cannot figure out what.
 Any help is greatly appreciated!

 Max
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user


-- 
Johan Lundberg
NORDUnet NUNOC
lundb...@nordu.net
+46(0)8 207860
Tulegatan 11
113 53 Stockholm
Sweden
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user