← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/more-thunder into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/more-thunder into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/more-thunder/+merge/46406

Change IArchive.dependencies and IArchive.getArchiveDependency from using SQLObject calls to using Storm directly. This does not change any tests, but all of the existing test_archive tests pass.
-- 
https://code.launchpad.net/~stevenk/launchpad/more-thunder/+merge/46406
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/more-thunder into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py	2011-01-14 10:41:20 +0000
+++ lib/lp/soyuz/browser/archive.py	2011-01-16 05:04:01 +0000
@@ -1476,7 +1476,7 @@
         PPA.
         """
         terms = []
-        for archive_dependency in self.context.dependencies:
+        for archive_dependency in self.dependencies:
             dependency = archive_dependency.dependency
             if not dependency.is_ppa:
                 continue
@@ -1612,7 +1612,7 @@
     @cachedproperty
     def has_dependencies(self):
         """Whether or not the PPA has recorded dependencies."""
-        return bool(self.context.dependencies)
+        return bool(self.dependencies)
 
     @property
     def messages(self):

=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py	2011-01-15 06:32:40 +0000
+++ lib/lp/soyuz/model/archive.py	2011-01-16 05:04:01 +0000
@@ -7,8 +7,12 @@
 
 __metaclass__ = type
 
-__all__ = ['Archive', 'ArchiveSet']
+__all__ = [
+    'Archive',
+    'ArchiveSet'
+    ]
 
+import operator
 import re
 
 from lazr.lifecycle.event import ObjectCreatedEvent
@@ -67,6 +71,9 @@
     IStoreSelector,
     MAIN_STORE,
     )
+from canonical.launchpad.components.decoratedresultset import (
+    DecoratedResultSet,
+    )
 from canonical.launchpad.webapp.url import urlappend
 from lp.app.errors import NotFoundError
 from lp.archivepublisher.debversion import Version
@@ -366,16 +373,15 @@
 
     @property
     def dependencies(self):
-        query = """
-            ArchiveDependency.dependency = Archive.id AND
-            Archive.owner = Person.id AND
-            ArchiveDependency.archive = %s
-        """ % sqlvalues(self)
-        clauseTables = ["Archive", "Person"]
-        orderBy = ['Person.displayname']
-        dependencies = ArchiveDependency.select(
-            query, clauseTables=clauseTables, orderBy=orderBy)
-        return dependencies
+        # Avoid circular imports
+        from lp.registry.model.person import Person
+        return DecoratedResultSet(
+            Store.of(self).find(
+                (ArchiveDependency, Archive),
+                ArchiveDependency.archive == self,
+                ArchiveDependency.dependencyID == Archive.id,
+                Archive.ownerID == Person.id).order_by(Person.displayname),
+            operator.itemgetter(0))
 
     @property
     def debug_archive(self):
@@ -904,8 +910,9 @@
 
     def getArchiveDependency(self, dependency):
         """See `IArchive`."""
-        return ArchiveDependency.selectOneBy(
-            archive=self, dependency=dependency)
+        return Store.of(self).find(
+            ArchiveDependency, Archive.id == self.id,
+            ArchiveDependency.dependencyID == dependency.id).one()
 
     def removeArchiveDependency(self, dependency):
         """See `IArchive`."""


Follow ups