X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=93ec11720379e99549272cae3af94718a2bfacba;hb=d6fb77d2760192195245e87d6f60a418c465d0b1;hp=72453f643d26dc35b768395d5d9886264d49b3eb;hpb=4830d9be143c7645ea932b53fae095e275ad7814;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 72453f64..93ec1172 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -46,7 +46,7 @@ from inspect import getargspec import sqlalchemy from sqlalchemy import create_engine, Table, MetaData, Column, Integer -from sqlalchemy.orm import sessionmaker, mapper, relation, object_session +from sqlalchemy.orm import sessionmaker, mapper, relation, object_session, backref from sqlalchemy import types as sqltypes # Don't remove this, we re-export the exceptions to scripts which import us @@ -1567,8 +1567,8 @@ __all__.append('get_location') ################################################################################ class Maintainer(object): - def __init__(self, *args, **kwargs): - pass + def __init__(self, name = None): + self.name = name def __repr__(self): return '''''' % (self.name, self.maintainer_id) @@ -2106,8 +2106,9 @@ __all__.append('get_sections') ################################################################################ class DBSource(object): - def __init__(self, *args, **kwargs): - pass + def __init__(self, maintainer = None, changedby = None): + self.maintainer = maintainer + self.changedby = changedby def __repr__(self): return '' % (self.source, self.version) @@ -2852,8 +2853,10 @@ class DBConn(object): def __setupmappers(self): mapper(Architecture, self.tbl_architecture, - properties = dict(arch_id = self.tbl_architecture.c.id, - suites = relation(Suite, secondary=self.tbl_suite_architectures, backref='architectures', order_by='suite_name'))) + properties = dict(arch_id = self.tbl_architecture.c.id, + suites = relation(Suite, secondary=self.tbl_suite_architectures, + order_by='suite_name', + backref=backref('architectures', order_by='arch_string')))) mapper(Archive, self.tbl_archive, properties = dict(archive_id = self.tbl_archive.c.id, @@ -3018,7 +3021,11 @@ class DBConn(object): archive_type = self.tbl_location.c.type)) mapper(Maintainer, self.tbl_maintainer, - properties = dict(maintainer_id = self.tbl_maintainer.c.id)) + properties = dict(maintainer_id = self.tbl_maintainer.c.id, + maintains_sources = relation(DBSource, backref='maintainer', + primaryjoin=(self.tbl_maintainer.c.id==self.tbl_source.c.maintainer)), + changed_sources = relation(DBSource, backref='changedby', + primaryjoin=(self.tbl_maintainer.c.id==self.tbl_source.c.changedby)))) mapper(NewComment, self.tbl_new_comments, properties = dict(comment_id = self.tbl_new_comments.c.id)) @@ -3054,19 +3061,15 @@ class DBConn(object): properties = dict(source_id = self.tbl_source.c.id, version = self.tbl_source.c.version, maintainer_id = self.tbl_source.c.maintainer, - maintainer = relation(Maintainer, - primaryjoin=(self.tbl_source.c.maintainer==self.tbl_maintainer.c.id)), poolfile_id = self.tbl_source.c.file, poolfile = relation(PoolFile), fingerprint_id = self.tbl_source.c.sig_fpr, fingerprint = relation(Fingerprint), changedby_id = self.tbl_source.c.changedby, - changedby = relation(Maintainer, - primaryjoin=(self.tbl_source.c.changedby==self.tbl_maintainer.c.id)), srcfiles = relation(DSCFile, primaryjoin=(self.tbl_source.c.id==self.tbl_dsc_files.c.source)), - srcassociations = relation(SrcAssociation, - primaryjoin=(self.tbl_source.c.id==self.tbl_src_associations.c.source)), + suites = relation(Suite, secondary=self.tbl_src_associations, + backref='sources'), srcuploaders = relation(SrcUploader))) mapper(SourceACL, self.tbl_source_acl,