Vertex

class mogwai.models.vertex.EnumVertexBaseMeta

This metaclass allows you to access MyVertexModel as if it were an enum. Ex. MyVertexModel.FOO

The values are cached in a dictionary. This is useful if the number of MyVertexModels is small, however it it grows too large, you should be doing it a different way.

This looks for a special (optional) function named enum_generator in your model and calls that to generate the ENUM for the model.

There is an additional optional model attribute that can be set __enum_id_only__ (defaults to True) which dictates whether or not just the Vertex ID is stored, or the whole Vertex in cache.

enums = None
mro() → list

return a type’s method resolution order

class mogwai.models.vertex.Vertex(**values)

The Vertex model base class.

The element type is auto-generated from the subclass name, but can optionally be set manually

exception DoesNotExist

Object not found in database

args
message
Vertex.FACTORY_CLASS = None
exception Vertex.MultipleObjectsReturned

Multiple objects returned on unique key lookup

args
message
exception Vertex.WrongElementType

Unique lookup with key corresponding to vertex of different type

args
message
classmethod Vertex.all(ids=, []as_dict=False, match_length=True, *args, **kwargs)

Load all vertices with the given ids from the graph. By default this will return a list of vertices but if as_dict is True then it will return a dictionary containing ids as keys and vertices found as values.

Parameters:
  • ids (list) – A list of titan ids
  • as_dict (boolean) – Toggle whether to return a dictionary or list
Return type:

dict | list

Vertex.as_dict()

Returns a map of column names to cleaned values

Return type:dict
Vertex.as_save_params()

Returns a map of property names to cleaned values containing only the properties which should be persisted on save.

Return type:dict
Vertex.bothE(*labels, **kwargs)

Return a list of edges both incoming and outgoing from this vertex.

Parameters:
  • label (str or BaseEdge or None) – The edge label to be traversed (optional)
  • limit (int or None) – The number of the page to start returning results at
  • offset (int or None) – The maximum number of results to return
  • types (list) – A list of allowed element types
Vertex.bothV(*labels, **kwargs)

Return a list of vertices both incoming and outgoing from this vertex.

Parameters:
  • label (str or BaseEdge or None) – The edge label to be traversed (optional)
  • limit (int or None) – The number of the page to start returning results at
  • offset (int or None) – The maximum number of results to return
  • types (list) – A list of allowed element types
classmethod Vertex.create(*args, **kwargs)

Create a new element with the given information.

Vertex.delete()

Delete the current vertex from the graph.

Vertex.delete_inE(*labels)

Delete all incoming edges with the given label.

Vertex.delete_inV(*labels)

Delete all incoming vertices connected with edges with the given label.

Vertex.delete_outE(*labels)

Delete all outgoing edges with the given label.

Vertex.delete_outV(*labels)

Delete all outgoing vertices connected with edges with the given label.

classmethod Vertex.deserialize(data)

Deserializes rexpro response into vertex or edge objects

Vertex.element_type = None
classmethod Vertex.find_by_value(field, value, as_dict=False)

Returns vertices that match the given field/value pair.

Parameters:
  • field (str) – The field to search
  • value (str) – The value of the field
  • as_dict (boolean) – Return results as a dictionary
Return type:

[mogwai.models.Vertex]

classmethod Vertex.get(id, *args, **kwargs)

Look up vertex by its ID. Raises a DoesNotExist exception if a vertex with the given vid was not found. Raises a MultipleObjectsReturned exception if the vid corresponds to more than one vertex in the graph.

Parameters:id (str) – The ID of the vertex
Return type:mogwai.models.Vertex
classmethod Vertex.get_element_type()

Returns the element type for this vertex.

@returns: str

classmethod Vertex.get_property_by_name(key)

Get’s the db_field_name of a property by key

Parameters:key (basestring | str) – attribute of the model
Return type:basestring | str | None
Vertex.gremlin_path = u'vertex.groovy'
Vertex.id
Vertex.inE(*labels, **kwargs)

Return a list of edges with the given label coming into this vertex.

Parameters:
  • label (str or BaseEdge) – The edge label to be traversed
  • limit (int or None) – The number of the page to start returning results at
  • offset (int or None) – The maximum number of results to return
  • types (list) – A list of allowed element types
Vertex.inV(*labels, **kwargs)

Return a list of vertices reached by traversing the incoming edge with the given label.

Parameters:
  • label (str or BaseEdge) – The edge label to be traversed
  • limit (int or None) – The number of the page to start returning results at
  • offset (int or None) – The maximum number of results to return
  • types (list) – A list of allowed element types
Vertex.items()
Vertex.keys()
Vertex.outE(*labels, **kwargs)

Return a list of edges with the given label going out of this vertex.

Parameters:
  • label (str or BaseEdge) – The edge label to be traversed
  • limit (int or None) – The number of the page to start returning results at
  • offset (int or None) – The maximum number of results to return
  • types (list) – A list of allowed element types
Vertex.outV(*labels, **kwargs)

Return a list of vertices reached by traversing the outgoing edge with the given label.

Parameters:
  • labels (str or BaseEdge) – pass in the labels to follow in as positional arguments
  • limit (int or None) – The number of the page to start returning results at
  • offset (int or None) – The maximum number of results to return
  • types (list) – A list of allowed element types
Vertex.pre_save()

Pre-save hook which is run before saving an element

Vertex.pre_update(**values)

Override this to perform pre-update validation

Vertex.query()
Vertex.reload(*args, **kwargs)

Reload the given element from the database.

Vertex.save(*args, **kwargs)

Save the current vertex using the configured save strategy, the default save strategy is to re-save all fields every time the object is saved.

classmethod Vertex.translate_db_fields(data)

Translates field names from the database into field names used in our model

this is for cases where we’re saving a field under a different name than it’s model property

Parameters:data – dict
Return type:dict
Vertex.update(**values)

performs an update of this element with the given values and returns the saved object

Vertex.validate()

Cleans and validates the field values

Vertex.validate_field(field_name, val)

Perform the validations associated with the field with the given name on the value passed.

Parameters:
  • field_name (str) – The name of property whose validations will be run
  • val (mixed) – The value to be validated
Vertex.values()
class mogwai.models.vertex.VertexMetaClass

Metaclass for vertices.

mro() → list

return a type’s method resolution order