]> err.no Git - dak/commitdiff
Carefully add a backref from PoolFile to Location.
authorTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 21:05:03 +0000 (22:05 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 21:05:03 +0000 (22:05 +0100)
Using lazy='dynamic' makes sure that property Location.files is not a very huge
list but a query object that can be iterated or .filter()-ed.

Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py

index 93ec11720379e99549272cae3af94718a2bfacba..75e56cd9a9d9d13cc75af5fd1b3472f375ab0d56 100755 (executable)
@@ -2945,7 +2945,11 @@ class DBConn(object):
                properties = dict(file_id = self.tbl_files.c.id,
                                  filesize = self.tbl_files.c.size,
                                  location_id = self.tbl_files.c.location,
-                                 location = relation(Location)))
+                                 location = relation(Location,
+                                     # using lazy='dynamic' in the back
+                                     # reference because we have A LOT of
+                                     # files in one location
+                                     backref=backref('files', lazy='dynamic'))))
 
         mapper(Fingerprint, self.tbl_fingerprint,
                properties = dict(fingerprint_id = self.tbl_fingerprint.c.id,