-
Notifications
You must be signed in to change notification settings - Fork 0
/
Connection.py
36 lines (31 loc) · 1.09 KB
/
Connection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
#
# Abstraction of the connection between two Node objects
#
# FIXME: this is still part of the locator.py horror, is there
# a better way of doing this?
from locator import Base
if Base != object.__class__:
from sqlalchemy import Column, Integer, String
class Connection(Base):
if Base != object.__class__:
__tablename__ = 'connection'
# Multiple definitions of the primary_key attribute as True,
# in the sqlite dialect, make a composite primary key, which
# is what we want here
id1 = Column(String, primary_key=True)
id2 = Column(String, primary_key=True)
class1 = Column(String)
class2 = Column(String)
def __init__(self, id1, id2, class1, class2):
assert(id1 != None and id2 != None)
assert(class1 != None and class2 != None)
self.id1 = id1
self.id2 = id2
self.class1 = class1
self.class2 = class2
def get_id(self):
return (self.id1, self.id2)
def get_class(self):
return (self.class1, self.class2)
# vim: set et sts=4 sw=4: