[Neo] Inheriting class neo4j.GraphDatabase

Tobias Ivarsson tobias.ivarsson at neotechnology.com
Thu Apr 1 11:32:03 CEST 2010

The GraphDatabase class in the neo4j Python library is extended behind the
scenes the first time it is instantiated, this is what enables the backend
to be loaded lazily. This has the side effect that it's not possible to
create your own subclasses of it.

I could probably modify it to work with subclasses, but I don't really see a
use case for that. Wouldn't it be easier and cleaner for you to implement
your added functionality as a wrapping library?


On Thu, Apr 1, 2010 at 10:42 AM, Subhajit Ghosh
<i.subhajit.ghosh at gmail.com>wrote:

> Hi,
> I am trying to create a class in Python which will inherit from
> neo4j.GraphDatabase. The reason why i am doing so is i want to do some
> validations when adding a node to the graph and also add several utility
> methods for graph traversals. However the inheritance class does not seem
> to
> work. I am not able to call the subclass's methods.
> import neo4j
> class Test(neo4j.GraphDatabase):
> dummy = 1
> n = Test("testdb")
> print(n.__class__)  # returns <class 'neo4j._core.GraphDatabase'>
> Am i doing something wrong here?
> For now, I am delegating all calls to a embedded GraphDatabase object in my
> class. But this makes the code verbose.
> Please suggest.
> Thanks,
> Subhajit
> _______________________________________________
> Neo mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user

Tobias Ivarsson <tobias.ivarsson at neotechnology.com>
Hacker, Neo Technology
Cellphone: +46 706 534857

More information about the User mailing list