From 790bd8d1f10012d547519a1ddb55464b969b54ef Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt Date: Mon, 6 Aug 2012 17:51:57 +0200 Subject: [PATCH] daklib/dbconn.py (PoolFile): add component property --- daklib/dbconn.py | 7 +++++++ 1 file changed, 7 insertions(+) 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) -- 2.39.5