]> err.no Git - dak/commitdiff
daklib/dbconn.py (PoolFile): add component property
authorAnsgar Burchardt <ansgar@debian.org>
Mon, 6 Aug 2012 15:51:57 +0000 (17:51 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Sat, 11 Aug 2012 11:43:04 +0000 (13:43 +0200)
daklib/dbconn.py

index e320a78f0da17d9e4b0adbfd863ae7d0c988126d..1972e412af81e4a5bad852c30a14f13405945165 100644 (file)
@@ -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)