API: Internals

Service Root

class py2neo.ServiceRoot[source]

Wrapper for the base REST resource exposed by a running Neo4j server, corresponding to the / URI. If no URI is supplied to the constructor, a value is taken from the NEO4J_URI environment variable (if set) otherwise a default of http://localhost:7474/ is used.

graph

The graph exposed by this service.

Return type:Graph
resource

The contained resource object for this instance.

Return type:py2neo.Resource
uri

The full URI of the contained resource.

Resources

class py2neo.Resource(uri, metadata=None, headers=None)[source]

Base class for all local resources mapped to remote counterparts.

delete(headers=None, **kwargs)[source]

Perform an HTTP DELETE to this resource.

Parameters:
  • headers – Extra headers to pass in the request.
  • kwargs – Other arguments to pass to the underlying httpstream method.
Return type:

httpstream.Response

Raises:

py2neo.GraphError

error_class

The class of error raised by failure responses from this resource.

alias of GraphError

get(headers=None, redirect_limit=5, **kwargs)[source]

Perform an HTTP GET to this resource.

Parameters:
  • headers – Extra headers to pass in the request.
  • redirect_limit – Maximum number of times to follow redirects.
  • kwargs – Other arguments to pass to the underlying httpstream method.
Return type:

httpstream.Response

Raises:

py2neo.GraphError

graph

The parent graph of this resource.

Return type:Graph
headers

The HTTP headers sent with this resource.

metadata

Metadata received in the last HTTP response.

post(body=None, headers=None, **kwargs)[source]

Perform an HTTP POST to this resource.

Parameters:
  • body – The payload of this request.
  • headers – Extra headers to pass in the request.
  • kwargs – Other arguments to pass to the underlying httpstream method.
Return type:

httpstream.Response

Raises:

py2neo.GraphError

put(body=None, headers=None, **kwargs)[source]

Perform an HTTP PUT to this resource.

Parameters:
  • body – The payload of this request.
  • headers – Extra headers to pass in the request.
  • kwargs – Other arguments to pass to the underlying httpstream method.
Return type:

httpstream.Response

Raises:

py2neo.GraphError

ref

The URI of this resource relative to its graph.

Return type:string
resolve(reference, strict=True)[source]

Resolve a URI reference against the URI for this resource, returning a new resource represented by the new target URI.

Parameters:
  • reference – Relative URI to resolve.
  • strict – Strict mode flag.
Return type:

Resource

service_root

The root service associated with this resource.

Returns:ServiceRoot
class py2neo.ResourceTemplate(uri_template)[source]

A factory class for producing Resource objects dynamically based on a template URI.

error_class

The class of error raised by failure responses from resources produced by this template.

alias of GraphError

expand(**values)[source]

Produce a resource instance by substituting values into the stored template URI.

Parameters:values – A set of named values to plug into the template URI.
Return type:Resource
uri_template

The URI template string of this resource template.

class py2neo.Service[source]

Base class for objects that can be optionally bound to a remote resource. This class is essentially a container for a Resource instance.

bind(uri, metadata=None)[source]

Associate this service with a remote resource.

Parameters:
  • uri – The URI identifying the remote resource to which to bind.
  • metadata – Dictionary of initial metadata to attach to the contained resource.
bound

True if this object is bound to a remote resource, False otherwise.

error_class

The class of error raised by failure responses from the contained resource.

alias of GraphError

graph

The graph associated with the remote resource.

Return type:Graph
ref

The URI of the remote resource relative to its graph.

Return type:string
resource

The remote resource to which this object is bound.

Return type:Resource
Raises:py2neo.BindError
service_root

The root service associated with the remote resource.

Returns:ServiceRoot
unbind()[source]

Detach this object from any remote resource.

uri

The full URI of the remote resource.

Extensions

class py2neo.ServerPlugin(graph, name)[source]

Base class for server plugins.

class py2neo.UnmanagedExtension(graph, path)[source]

Base class for unmanaged extensions.