Clean database storage code

This commit is contained in:
Guillaume Ayoub 2013-04-20 12:59:44 +02:00
parent 16c6f55ebd
commit a01e4d18e1

View File

@ -43,7 +43,8 @@ class DBCollection(Base):
path = Column(String, primary_key=True) path = Column(String, primary_key=True)
parent_path = Column(String, ForeignKey("collection.path")) parent_path = Column(String, ForeignKey("collection.path"))
parent = relationship("DBCollection", backref="children", remote_side=[path]) parent = relationship(
"DBCollection", backref="children", remote_side=[path])
class DBItem(Base): class DBItem(Base):
@ -61,7 +62,8 @@ class DBHeader(Base):
key = Column(String, primary_key=True) key = Column(String, primary_key=True)
value = Column(String) value = Column(String)
collection_path = Column(String, ForeignKey("collection.path"), primary_key=True) collection_path = Column(
String, ForeignKey("collection.path"), primary_key=True)
collection = relationship("DBCollection", backref="headers") collection = relationship("DBCollection", backref="headers")
@ -83,7 +85,8 @@ class DBProperty(Base):
key = Column(String, primary_key=True) key = Column(String, primary_key=True)
value = Column(String) value = Column(String)
collection_path = Column(String, ForeignKey("collection.path"), primary_key=True) collection_path = Column(
String, ForeignKey("collection.path"), primary_key=True)
collection = relationship( collection = relationship(
"DBCollection", backref="properties", cascade="delete") "DBCollection", backref="properties", cascade="delete")
@ -97,7 +100,6 @@ class Collection(ical.Collection):
def __del__(self): def __del__(self):
self.session.commit() self.session.commit()
#super(Collection, self).__del__()
def _query(self, item_types): def _query(self, item_types):
item_objects = [] item_objects = []