launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25493
[Merge] ~cjwatson/launchpad:stormify-archivedependency into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:stormify-archivedependency into launchpad:master.
Commit message:
Convert ArchiveDependency to Storm
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/392161
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:stormify-archivedependency into launchpad:master.
diff --git a/lib/lp/soyuz/browser/archive.py b/lib/lp/soyuz/browser/archive.py
index 3170ea0..5b80a58 100644
--- a/lib/lp/soyuz/browser/archive.py
+++ b/lib/lp/soyuz/browser/archive.py
@@ -1798,7 +1798,7 @@ class ArchiveEditDependenciesView(ArchiveViewBase, LaunchpadFormView):
@cachedproperty
def has_dependencies(self):
"""Whether or not the PPA has recorded dependencies."""
- return bool(self.context.dependencies)
+ return not self.context.dependencies.is_empty()
@property
def messages(self):
diff --git a/lib/lp/soyuz/doc/archive.txt b/lib/lp/soyuz/doc/archive.txt
index ad7f3d7..f03223a 100644
--- a/lib/lp/soyuz/doc/archive.txt
+++ b/lib/lp/soyuz/doc/archive.txt
@@ -746,7 +746,7 @@ required dependencies when building.
>>> def print_dependencies(archive):
... dependencies = archive.dependencies
- ... if not dependencies:
+ ... if dependencies.is_empty():
... print("No dependencies recorded.")
... return
... for dep in dependencies:
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 529dc7a..38ce6af 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -499,16 +499,13 @@ class Archive(SQLBase):
@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
+ # Circular import.
+ from lp.registry.model.person import Person
+ return IStore(ArchiveDependency).find(
+ ArchiveDependency,
+ ArchiveDependency.dependency == Archive.id,
+ Archive.owner == Person.id,
+ ArchiveDependency.archive == self).order_by(Person.display_name)
@cachedproperty
def default_component(self):
@@ -1127,8 +1124,8 @@ class Archive(SQLBase):
def getArchiveDependency(self, dependency):
"""See `IArchive`."""
- return ArchiveDependency.selectOneBy(
- archive=self, dependency=dependency)
+ return IStore(ArchiveDependency).find(
+ ArchiveDependency, archive=self, dependency=dependency).one()
def removeArchiveDependency(self, dependency):
"""See `IArchive`."""
diff --git a/lib/lp/soyuz/model/archivedependency.py b/lib/lp/soyuz/model/archivedependency.py
index 737c167..8fcd899 100644
--- a/lib/lp/soyuz/model/archivedependency.py
+++ b/lib/lp/soyuz/model/archivedependency.py
@@ -7,40 +7,54 @@ __metaclass__ = type
__all__ = ['ArchiveDependency']
-
-from sqlobject import ForeignKey
+import pytz
+from storm.locals import (
+ DateTime,
+ Int,
+ Reference,
+ Store,
+ )
from zope.interface import implementer
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.database.constants import UTC_NOW
-from lp.services.database.datetimecol import UtcDateTimeCol
-from lp.services.database.enumcol import EnumCol
-from lp.services.database.sqlbase import SQLBase
+from lp.services.database.enumcol import DBEnum
+from lp.services.database.stormbase import StormBase
from lp.soyuz.adapters.archivedependencies import get_components_for_context
from lp.soyuz.interfaces.archivedependency import IArchiveDependency
@implementer(IArchiveDependency)
-class ArchiveDependency(SQLBase):
+class ArchiveDependency(StormBase):
"""See `IArchiveDependency`."""
- _table = 'ArchiveDependency'
- _defaultOrder = 'id'
+ __storm_table__ = 'ArchiveDependency'
+ __storm_order__ = 'id'
+
+ id = Int(primary=True)
- date_created = UtcDateTimeCol(
- dbName='date_created', notNull=True, default=UTC_NOW)
+ date_created = DateTime(
+ name='date_created', tzinfo=pytz.UTC, allow_none=False,
+ default=UTC_NOW)
- archive = ForeignKey(
- foreignKey='Archive', dbName='archive', notNull=True)
+ archive_id = Int(name='archive', allow_none=False)
+ archive = Reference(archive_id, 'Archive.id')
- dependency = ForeignKey(
- foreignKey='Archive', dbName='dependency', notNull=True)
+ dependency_id = Int(name='dependency', allow_none=False)
+ dependency = Reference(dependency_id, 'Archive.id')
- pocket = EnumCol(
- dbName='pocket', notNull=True, schema=PackagePublishingPocket)
+ pocket = DBEnum(
+ name='pocket', allow_none=False, enum=PackagePublishingPocket)
- component = ForeignKey(
- foreignKey='Component', dbName='component')
+ component_id = Int(name='component', allow_none=True)
+ component = Reference(component_id, 'Component.id')
+
+ def __init__(self, archive, dependency, pocket, component=None):
+ super(ArchiveDependency, self).__init__()
+ self.archive = archive
+ self.dependency = dependency
+ self.pocket = pocket
+ self.component = component
@property
def component_name(self):
@@ -72,3 +86,6 @@ class ArchiveDependency(SQLBase):
self.component, distroseries, self.pocket))
return "%s (%s)" % (pocket_title, component_part)
+
+ def destroySelf(self):
+ Store.of(self).remove(self)