From: Ansgar Burchardt Date: Mon, 6 Aug 2012 15:51:57 +0000 (+0200) Subject: daklib/dbconn.py (PoolFile): add component property X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=790bd8d1f10012d547519a1ddb55464b969b54ef;p=dak daklib/dbconn.py (PoolFile): add component property --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index e320a78f..1972e412 100644 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -1440,6 +1440,13 @@ class PoolFile(ORMObject): af = session.query(ArchiveFile).join(Archive).filter(ArchiveFile.file == self).first() return af.path + @property + def component(self): + session = DBConn().session().object_session(self) + component_id = session.query(ArchiveFile.component_id).filter(ArchiveFile.file == self) \ + .group_by(ArchiveFile.component_id).one() + return session.query(Component).get(component_id) + @property def basename(self): return os.path.basename(self.filename)