class SQLObjectVersionTable(sqlobject.SQLObject): """ This table is used to store information about the database and its version (used with record and update commands). """ class sqlmeta: table = 'sqlobject_db_version' version = col.StringCol() updated = col.DateTimeCol(default=col.DateTimeCol.now)
def __addtoclass__(self, soClass, name): self.name = name self.soClass = soClass attrs = { 'dateArchived': col.DateTimeCol(default=datetime.now), 'master': col.ForeignKey(self.soClass.__name__), 'masterClass': self.soClass, 'extraCols': self.extraCols } getColumns(attrs, self.soClass) attrs.update(self.extraCols) self.versionClass = type(self.soClass.__name__ + 'Versions', (Version, ), attrs) if '_connection' in self.soClass.__dict__: self.versionClass._connection = \ self.soClass.__dict__['_connection'] events.listen(self.createTable, soClass, events.CreateTableSignal) events.listen(self.rowUpdate, soClass, events.RowUpdateSignal)
class Episode(SQLObject): "A DB entry of things we want to remember about an episode" hash = col.UnicodeCol(unique=True, alternateID=True) pubdate = col.DateTimeCol() played = col.BoolCol(default=False)