class Place(element.Vertex): name = properties.Property(properties.String) zipcode = properties.Property(properties.Integer, db_name_factory=db_name_factory) historical_name = HistoricalName(properties.String, card=Cardinality.list_) important_numbers = element.VertexProperty(properties.Integer, card=Cardinality.set_) incorporated = element.VertexProperty(properties.Boolean, default=False)
class Person(element.Vertex): __label__ = 'person' name = properties.Property(properties.String) age = properties.Property(properties.Integer, db_name='custom__person__age') birthplace = element.VertexProperty(properties.String) nicknames = element.VertexProperty( properties.String, card=Cardinality.list)
class Session(element.Vertex): session_id = properties.Property(properties.String) ip_address = element.VertexProperty(properties.String, card=Cardinality.set_) start = properties.Property(properties.Float) end = properties.Property(properties.Float) timeout = properties.Property(properties.Float) #assigned_to = Relationship('User', 'ASSIGNED_TO') #log_in = Relationship('Tenant', 'LOG_IN', model=LogsIn) #log_out = Relationship('Tenant', 'LOGGED_OUT', model=LogsOut) #time_out = Relationship('Tenant', 'TIME_OUT', model=TimesOut) #launches = Relationship('ApplicationInstance', 'LAUNCHES', model=Launches) #enters = Relationship('ApplicationInstance', 'ENTERS', model=Enters) #exits = Relationship('ApplicationInstance', 'EXITS', model=Exits) #accesses = Relationship('ScreenInstance', 'ACCESSES', model=Accesses) #connected_with = Relationship('Browser', 'CONNECTED_WITH') def end_session_at(self, end_datetime): self.end = end_datetime self.save() def timeout_at(self, timeout_datetime): self.timeout = timeout_datetime self.save() @property def serialize(self): return { '_id': self.id, 'session_id': self.session_id, 'ip_addresses': json.dumps(self.ip_address).replace("u\'", "\'"), 'start': myconverter(self.start), 'end': myconverter(self.end), 'timeout': myconverter(self.timeout_at) }
def test_vertex_property_default(): """Makes sure that a brand new VertexProperty (i.e., with no value set) is still representable. Addresses issue #52. """ vp = element.VertexProperty(int) assert repr(vp) == "<VertexProperty(type=0, value=None)"
class MyEdge(element.Edge): vert_prop = element.VertexProperty(properties.String)
class Place(element.Vertex): name = properties.Property(properties.String) zipcode = properties.Property(properties.Integer) historical_name = HistoricalName(properties.String, card=Cardinality.list) important_numbers = element.VertexProperty( properties.Integer, card=Cardinality.set)