X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=e1e21d2b2b1f10a386dd42c50460287d7e6c8f4d;hb=221c511735a22974ac5ee9e1d2d5d52bf29e263e;hp=1acb20d48621c31c00d79601f6498870b69325c0;hpb=6fb7b56027682a063156f9134aa9093c00f90e4e;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 1acb20d4..e1e21d2b 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -849,9 +849,9 @@ __all__.append('ChangePendingSource') ################################################################################ -class Component(object): - def __init__(self, *args, **kwargs): - pass +class Component(ORMObject): + def __init__(self, component_name = None): + self.component_name = component_name def __eq__(self, val): if isinstance(val, str): @@ -865,8 +865,12 @@ class Component(object): # This signals to use the normal comparison operator return NotImplemented - def __repr__(self): - return '' % self.component_name + def properties(self): + return ['component_name', 'component_id', 'description', 'location', \ + 'meets_dfsg'] + + def not_null_constraints(self): + return ['component_name'] __all__.append('Component') @@ -1572,9 +1576,12 @@ __all__.append('get_dbchange') ################################################################################ +# TODO: Why do we have a separate Location class? Can't it be fully integrated +# into class Component? class Location(ORMObject): - def __init__(self, path = None): + def __init__(self, path = None, component = None): self.path = path + self.component = component # the column 'type' should go away, see comment at mapper self.archive_type = 'pool' @@ -2989,7 +2996,8 @@ class DBConn(object): mapper(Component, self.tbl_component, properties = dict(component_id = self.tbl_component.c.id, - component_name = self.tbl_component.c.name)) + component_name = self.tbl_component.c.name), + extension = validator) mapper(DBConfig, self.tbl_config, properties = dict(config_id = self.tbl_config.c.id)) @@ -3081,7 +3089,8 @@ class DBConn(object): mapper(Location, self.tbl_location, properties = dict(location_id = self.tbl_location.c.id, component_id = self.tbl_location.c.component, - component = relation(Component), + component = relation(Component, \ + backref=backref('location', uselist = False)), archive_id = self.tbl_location.c.archive, archive = relation(Archive), # FIXME: the 'type' column is old cruft and