launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05633
[Merge] lp:~wgrant/launchpad/reconnect_stores-is-a-horrible-person into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/reconnect_stores-is-a-horrible-person into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/reconnect_stores-is-a-horrible-person/+merge/82844
Lots of tests in DatabaseFunctionalLayer or LaunchpadFunctionalLayer use reconnect_stores() to switch to another DB user, because the more sensible dbuser helpers only worked in ZopelessLayer. But I generalised them a few months back, so the tests can become simpler.
In addition to replacing the commit/reconnect_stores/stuff/commit/reconnect_stores with 'with dbuser', I also ripped out some of the object reloading that was necessary due to reconnect_stores' violent approach to connection changes.
No longer used except to restore the default DB config, reconnect_stores() no longer overrides. Instead it just resets the config if asked.
--
https://code.launchpad.net/~wgrant/launchpad/reconnect_stores-is-a-horrible-person/+merge/82844
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/reconnect_stores-is-a-horrible-person into lp:launchpad.
=== modified file 'lib/canonical/testing/layers.py'
--- lib/canonical/testing/layers.py 2011-11-03 22:13:25 +0000
+++ lib/canonical/testing/layers.py 2011-11-21 05:15:04 +0000
@@ -215,18 +215,15 @@
store.close()
-def reconnect_stores(database_config_section=None):
+def reconnect_stores(reset=False):
"""Reconnect Storm stores, resetting the dbconfig to its defaults.
After reconnecting, the database revision will be checked to make
sure the right data is available.
"""
disconnect_stores()
- if database_config_section:
- section = getattr(config, database_config_section)
- dbconfig.override(
- dbuser=getattr(section, 'dbuser', None),
- isolation_level=getattr(section, 'isolation_level', None))
+ if reset:
+ dbconfig.reset()
main_store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
assert main_store is not None, 'Failed to reconnect'
@@ -1353,7 +1350,7 @@
@profiled
def testSetUp(cls):
# Connect Storm
- reconnect_stores('launchpad')
+ reconnect_stores(reset=True)
@classmethod
@profiled
@@ -1382,7 +1379,7 @@
OpStats.resetStats()
# Connect Storm
- reconnect_stores('launchpad')
+ reconnect_stores(reset=True)
@classmethod
@profiled
@@ -1447,7 +1444,7 @@
def testSetUp(cls):
# LaunchpadZopelessLayer takes care of reconnecting the stores
if not LaunchpadZopelessLayer.isSetUp:
- reconnect_stores('launchpad')
+ reconnect_stores(reset=True)
@classmethod
@profiled
@@ -1480,7 +1477,7 @@
def testSetUp(cls):
# LaunchpadZopelessLayer takes care of reconnecting the stores
if not LaunchpadZopelessLayer.isSetUp:
- reconnect_stores('launchpad')
+ reconnect_stores(reset=True)
@classmethod
@profiled
=== modified file 'lib/lp/registry/browser/tests/distributionsourcepackage-views.txt'
--- lib/lp/registry/browser/tests/distributionsourcepackage-views.txt 2011-08-03 11:00:11 +0000
+++ lib/lp/registry/browser/tests/distributionsourcepackage-views.txt 2011-11-21 05:15:04 +0000
@@ -132,26 +132,18 @@
# Give the creators of the above source packages some soyuz
# karma for their efforts.
>>> from lp.registry.model.karma import KarmaCategory
+ >>> from lp.registry.model.karma import KarmaTotalCache
+ >>> from lp.testing.dbuser import dbuser
>>> soyuz_category = KarmaCategory.byName('soyuz')
>>> sourcepackagerelease = gedit_nightly_src_breezy.sourcepackagerelease
>>> gedit_name = sourcepackagerelease.sourcepackagename
>>> ppa_beta_owner_id = ppa_beta.owner.id
>>> ppa_nightly_owner_id = ppa_nightly.owner.id
- >>> transaction.commit()
-
- # XXX: Michael Nelson 2009-07-07 bug=396419. Currently there is no
- # test api call to switchDbUser that works for non-zopeless layers.
- # When bug 396419 is fixed, we can instead use
- # DatabaseLayer.switchDbUser() instead of reconnect_stores()
- >>> from canonical.testing.layers import reconnect_stores
- >>> reconnect_stores('karmacacheupdater')
- >>> from lp.registry.model.karma import KarmaTotalCache
- >>> cache_entry = KarmaTotalCache(
- ... person=ppa_beta_owner_id, karma_total=200)
- >>> cache_entry = KarmaTotalCache(
- ... person=ppa_nightly_owner_id, karma_total=201)
- >>> transaction.commit()
- >>> reconnect_stores('launchpad')
+ >>> with dbuser('karma'):
+ ... cache_entry = KarmaTotalCache(
+ ... person=ppa_beta_owner_id, karma_total=200)
+ ... cache_entry = KarmaTotalCache(
+ ... person=ppa_nightly_owner_id, karma_total=201)
# Because our connection has been closed during the reconnect, we
# need to get the distro and source package again.
=== modified file 'lib/lp/registry/browser/tests/product-portlet-packages-view.txt'
--- lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2011-08-28 08:36:14 +0000
+++ lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2011-11-21 05:15:04 +0000
@@ -23,21 +23,15 @@
>>> from lp.services.log.logger import BufferLogger
>>> logger = BufferLogger()
>>> from canonical.config import config
- >>> from canonical.testing.layers import reconnect_stores
+ >>> from lp.testing.dbuser import dbuser
>>> def updateCache():
... # Switch to the statistician user who is the only user with
... # write permission to the source package cache tables.
- ... transaction.commit()
- ... reconnect_stores(config.statistician.dbuser)
- ... ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
- ... DistributionSourcePackageCache.updateAll(
- ... ubuntu, archive=ubuntu.main_archive, log=logger,
- ... ztm=transaction)
- ... transaction.commit()
- ... reconnect_stores('launchpad')
- ... # Get ubuntu, our product, and the sourcepackage name again
- ... # since the transaction changed.
- ... ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
+ ... ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
+ ... with dbuser(config.statistician.dbuser):
+ ... DistributionSourcePackageCache.updateAll(
+ ... ubuntu, archive=ubuntu.main_archive, log=logger,
+ ... ztm=transaction)
... product = getUtility(IProductSet)['bingo']
... spn = getUtility(ISourcePackageNameSet)['bingo']
... login(ANONYMOUS)
=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py 2011-11-18 15:25:51 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py 2011-11-21 05:15:04 +0000
@@ -28,7 +28,6 @@
LessThan,
Not,
)
-import transaction
from zope.component import getUtility
from zope.security.proxy import (
ProxyFactory,
@@ -57,7 +56,6 @@
DatabaseFunctionalLayer,
LaunchpadFunctionalLayer,
LaunchpadZopelessLayer,
- reconnect_stores,
)
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.archivepublisher.debversion import Version
@@ -115,6 +113,7 @@
TestCaseWithFactory,
with_celebrity_logged_in,
)
+from lp.testing.dbuser import dbuser
from lp.testing.fakemethod import FakeMethod
from lp.testing.matchers import (
DocTestMatches,
@@ -608,14 +607,11 @@
# We need to switch to the initializedistroseries user to set the
# error_description on the given job. Which is a PITA.
distroseries = job.distroseries
- transaction.commit()
- reconnect_stores("initializedistroseries")
- job = self.job_source.get(distroseries)
- job.start()
- job.fail()
- job.notifyUserError(error)
- transaction.commit()
- reconnect_stores('launchpad')
+ with dbuser("initializedistroseries"):
+ job = self.job_source.get(distroseries)
+ job.start()
+ job.fail()
+ job.notifyUserError(error)
def test_initialization_failure_explanation_shown(self):
# When initialization has failed an explanation of the failure can be
=== modified file 'lib/lp/registry/tests/test_dsp_vocabularies.py'
--- lib/lp/registry/tests/test_dsp_vocabularies.py 2011-10-04 22:00:18 +0000
+++ lib/lp/registry/tests/test_dsp_vocabularies.py 2011-11-21 05:15:04 +0000
@@ -5,21 +5,17 @@
__metaclass__ = type
-import transaction
-
from zope.component import getUtility
from canonical.launchpad.webapp.vocabulary import IHugeVocabulary
-from canonical.testing.layers import (
- DatabaseFunctionalLayer,
- reconnect_stores,
- )
+from canonical.testing.layers import DatabaseFunctionalLayer
from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.vocabularies import DistributionSourcePackageVocabulary
from lp.soyuz.model.distributionsourcepackagecache import (
DistributionSourcePackageCache,
)
from lp.testing import TestCaseWithFactory
+from lp.testing.dbuser import dbuser
class TestDistributionSourcePackageVocabulary(TestCaseWithFactory):
@@ -221,16 +217,13 @@
else:
archive = self.factory.makeArchive(
distribution=distribution, purpose=archive)
- transaction.commit()
- reconnect_stores('statistician')
- DistributionSourcePackageCache(
- distribution=dsp.distribution,
- sourcepackagename=dsp.sourcepackagename,
- archive=archive,
- name=package_name,
- binpkgnames=binary_names)
- transaction.commit()
- reconnect_stores('launchpad')
+ with dbuser('statistician'):
+ DistributionSourcePackageCache(
+ distribution=dsp.distribution,
+ sourcepackagename=dsp.sourcepackagename,
+ archive=archive,
+ name=package_name,
+ binpkgnames=binary_names)
def test_searchForTerms_None(self):
# Searching for nothing gets you that.
=== modified file 'lib/lp/registry/tests/test_person.py'
--- lib/lp/registry/tests/test_person.py 2011-11-10 01:13:44 +0000
+++ lib/lp/registry/tests/test_person.py 2011-11-21 05:15:04 +0000
@@ -18,6 +18,7 @@
from zope.security.interfaces import Unauthorized
from zope.security.proxy import removeSecurityProxy
+from canonical.config import config
from canonical.database.sqlbase import cursor
from canonical.launchpad.database.account import Account
from canonical.launchpad.database.emailaddress import EmailAddress
@@ -36,10 +37,7 @@
IStore,
)
from canonical.launchpad.testing.pages import LaunchpadWebServiceCaller
-from canonical.testing.layers import (
- DatabaseFunctionalLayer,
- reconnect_stores,
- )
+from canonical.testing.layers import DatabaseFunctionalLayer
from lp.answers.model.answercontact import AnswerContact
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.blueprints.model.specification import Specification
@@ -89,11 +87,8 @@
TestCaseWithFactory,
)
from lp.testing._webservice import QueryCollector
+from lp.testing.dbuser import dbuser
from lp.testing.matchers import HasQueryCount
-from lp.testing.storm import (
- reload_dsp,
- reload_object,
- )
from lp.testing.views import create_initialized_view
@@ -814,20 +809,17 @@
user 'karma'. This invalidates the objects under test so they
must be retrieved again.
"""
- transaction.commit()
- reconnect_stores('karmacacheupdater')
- total = 0
- # Insert category total for person and project.
- for category_name, value in category_name_values:
- category = KarmaCategory.byName(category_name)
+ with dbuser('karma'):
+ total = 0
+ # Insert category total for person and project.
+ for category_name, value in category_name_values:
+ category = KarmaCategory.byName(category_name)
+ self.cache_manager.new(
+ value, person.id, category.id, product_id=product.id)
+ total += value
+ # Insert total cache for person and project.
self.cache_manager.new(
- value, person.id, category.id, product_id=product.id)
- total += value
- # Insert total cache for person and project.
- self.cache_manager.new(
- total, person.id, None, product_id=product.id)
- transaction.commit()
- reconnect_stores('launchpad')
+ total, person.id, None, product_id=product.id)
def _makeKarmaTotalCache(self, person, total):
"""Create a KarmaTotalCache entry.
@@ -836,11 +828,8 @@
user 'karma'. This invalidates the objects under test so they
must be retrieved again.
"""
- transaction.commit()
- reconnect_stores('karmacacheupdater')
- KarmaTotalCache(person=person.id, karma_total=total)
- transaction.commit()
- reconnect_stores('launchpad')
+ with dbuser('karma'):
+ KarmaTotalCache(person=person.id, karma_total=total)
class TestPersonSetMerge(TestCaseWithFactory, KarmaTestMixin):
@@ -864,13 +853,8 @@
def _do_merge(self, from_person, to_person, reviewer=None):
# Perform the merge as the db user that will be used by the jobs.
- transaction.commit()
- reconnect_stores('IPersonMergeJobSource')
- from_person = reload_object(from_person)
- to_person = reload_object(to_person)
- if reviewer is not None:
- reviewer = reload_object(reviewer)
- self.person_set.merge(from_person, to_person, reviewer=reviewer)
+ with dbuser(config.IPersonMergeJobSource.dbuser):
+ self.person_set.merge(from_person, to_person, reviewer=reviewer)
return from_person, to_person
def _get_testable_account(self, person, date_created, openid_identifier):
@@ -884,10 +868,8 @@
team = self.factory.makeTeam()
owner = team.teamowner
transaction.commit()
- reconnect_stores('IPersonMergeJobSource')
- team = reload_object(team)
- owner = reload_object(owner)
- self.person_set.delete(team, owner)
+ with dbuser(config.IPersonMergeJobSource.dbuser):
+ self.person_set.delete(team, owner)
notification_set = getUtility(IPersonNotificationSet)
notifications = notification_set.getNotificationsToSend()
self.assertEqual(0, notifications.count())
@@ -1101,7 +1083,7 @@
self.assertEqual([u'TO', u'FROM'], descriptions)
self.assertEqual(u'foo-1', recipes[1].name)
- def assertSubscriptionMerges(self, target, reloader=reload_object):
+ def assertSubscriptionMerges(self, target):
# Given a subscription target, we want to make sure that subscriptions
# that the duplicate person made are carried over to the merged
# account.
@@ -1114,12 +1096,10 @@
duplicate, person = self._do_merge(duplicate, person)
# The merged person has the subscription, and the duplicate person
# does not.
- target = reloader(target)
self.assertTrue(target.getSubscription(person) is not None)
self.assertTrue(target.getSubscription(duplicate) is None)
- def assertConflictingSubscriptionDeletes(self, target,
- reloader=reload_object):
+ def assertConflictingSubscriptionDeletes(self, target):
# Given a subscription target, we want to make sure that subscriptions
# that the duplicate person made that conflict with existing
# subscriptions in the merged account are deleted.
@@ -1135,7 +1115,6 @@
self._do_premerge(duplicate, person)
login_person(person)
duplicate, person = self._do_merge(duplicate, person)
- target = reloader(target)
# The merged person still has the original subscription, as shown
# by the marker name.
self.assertEqual(
@@ -1199,12 +1178,12 @@
def test_merge_with_sourcepackage_subscription(self):
# See comments in assertSubscriptionMerges.
dsp = self.factory.makeDistributionSourcePackage()
- self.assertSubscriptionMerges(dsp, reloader=reload_dsp)
+ self.assertSubscriptionMerges(dsp)
def test_merge_with_conflicting_sourcepackage_subscription(self):
# See comments in assertConflictingSubscriptionDeletes.
dsp = self.factory.makeDistributionSourcePackage()
- self.assertConflictingSubscriptionDeletes(dsp, reloader=reload_dsp)
+ self.assertConflictingSubscriptionDeletes(dsp)
def test_mergeAsync(self):
# mergeAsync() creates a new `PersonMergeJob`.
=== modified file 'lib/lp/registry/tests/test_teammembership.py'
--- lib/lp/registry/tests/test_teammembership.py 2011-11-04 21:02:33 +0000
+++ lib/lp/registry/tests/test_teammembership.py 2011-11-21 05:15:04 +0000
@@ -73,9 +73,9 @@
TestCase,
TestCaseWithFactory,
)
+from lp.testing.dbuser import dbuser
from lp.testing.mail_helpers import pop_notifications
from lp.testing.matchers import HasQueryCount
-from lp.testing.storm import reload_object
class TestTeamMembershipSetScripts(TestCaseWithFactory):
@@ -105,15 +105,10 @@
# Set expiration time to now
now = datetime.now(pytz.UTC)
removeSecurityProxy(teammembership).dateexpires = now
- transaction.commit()
- # Switch dbuser to the user running the membership flagging
- # cronscript. Reload the membership object so we can assert against
- # it.
- self.layer.switchDbUser(config.expiredmembershipsflagger.dbuser)
- reload_object(teammembership)
janitor = getUtility(ILaunchpadCelebrities).janitor
- membershipset.handleMembershipsExpiringToday(janitor)
+ with dbuser(config.expiredmembershipsflagger.dbuser):
+ membershipset.handleMembershipsExpiringToday(janitor)
self.assertEqual(
teammembership.status, TeamMembershipStatus.APPROVED)
=== modified file 'lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt'
--- lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt 2011-07-18 08:53:48 +0000
+++ lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt 2011-11-21 05:15:04 +0000
@@ -176,27 +176,18 @@
# Give the creators of the above source packages some soyuz
# karma for their efforts.
>>> from lp.registry.model.karma import KarmaTotalCache
+ >>> from lp.testing.dbuser import dbuser
>>> ppa_beta_owner_id = ppa_beta.owner.id
>>> ppa_nightly_owner_id = ppa_nightly.owner.id
>>> ppa_disabled_owner_id = ppa_disabled.owner.id
>>> ppa_disabled.disable()
- >>> transaction.commit()
-
- # XXX: Michael Nelson 2009-07-07 bug=396419. Currently there is no
- # test api call to switchDbUser that works for non-zopeless layers.
- # When bug 396419 is fixed, we can instead use
- # DatabaseLayer.switchDbUser() instead of reconnect_stores()
- >>> from canonical.testing.layers import reconnect_stores
- >>> reconnect_stores('karmacacheupdater')
- >>> from zope.component import getUtility
- >>> cache_entry = KarmaTotalCache(
- ... person=ppa_beta_owner_id, karma_total=200)
- >>> cache_entry = KarmaTotalCache(
- ... person=ppa_nightly_owner_id, karma_total=201)
- >>> cache_entry = KarmaTotalCache(
- ... person=ppa_disabled_owner_id, karma_total=202)
- >>> transaction.commit()
- >>> reconnect_stores('launchpad')
+ >>> with dbuser('karma'):
+ ... cache_entry = KarmaTotalCache(
+ ... person=ppa_beta_owner_id, karma_total=200)
+ ... cache_entry = KarmaTotalCache(
+ ... person=ppa_nightly_owner_id, karma_total=201)
+ ... cache_entry = KarmaTotalCache(
+ ... person=ppa_disabled_owner_id, karma_total=202)
>>> logout()
=== modified file 'lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt'
--- lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt 2011-08-23 08:33:15 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt 2011-11-21 05:15:04 +0000
@@ -250,20 +250,17 @@
>>> from zope.component import getUtility
>>> from canonical.config import config
>>> from lp.services.log.logger import BufferLogger
- >>> from canonical.testing.layers import reconnect_stores
>>> from lp.registry.interfaces.distribution import IDistributionSet
>>> from lp.soyuz.model.distroseriespackagecache import (
... DistroSeriesPackageCache)
+ >>> from lp.testing.dbuser import dbuser
>>> login('foo.bar@xxxxxxxxxxxxx')
- >>> transaction.commit()
- >>> reconnect_stores(config.statistician.dbuser)
>>> logger = BufferLogger()
>>> ubuntutest = getUtility(IDistributionSet).getByName('ubuntutest')
>>> breezy_autotest = ubuntutest.getSeries('breezy-autotest')
- >>> unused = DistroSeriesPackageCache.updateAll(
- ... breezy_autotest, ubuntutest.main_archive, logger, transaction)
- >>> transaction.commit()
- >>> reconnect_stores('launchpad')
+ >>> with dbuser(config.statistician.dbuser):
+ ... unused = DistroSeriesPackageCache.updateAll(
+ ... breezy_autotest, ubuntutest.main_archive, logger, transaction)
>>> logout()
>>> anon_browser.reload()
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2011-11-04 10:47:21 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2011-11-21 05:15:04 +0000
@@ -23,7 +23,6 @@
from canonical.testing.layers import (
DatabaseFunctionalLayer,
LaunchpadZopelessLayer,
- reconnect_stores,
ZopelessDatabaseLayer,
)
from lp.app.errors import NotFoundError
@@ -31,7 +30,6 @@
from lp.archivepublisher.diskpool import DiskPool
from lp.buildmaster.enums import BuildStatus
from lp.registry.interfaces.distribution import IDistributionSet
-from lp.registry.interfaces.distroseries import IDistroSeriesSet
from lp.registry.interfaces.person import IPersonSet
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.registry.interfaces.sourcepackage import SourcePackageUrgency
@@ -69,6 +67,7 @@
StormStatementRecorder,
TestCaseWithFactory,
)
+from lp.testing.dbuser import dbuser
from lp.testing.factory import LaunchpadObjectFactory
from lp.testing.matchers import HasQueryCount
@@ -553,23 +552,13 @@
distroseries=source_pub.distroseries,
source_package=source_pub.meta_sourcepackage)
- def updateDistroSeriesPackageCache(
- self, distroseries, restore_db_connection='launchpad'):
- # XXX: EdwinGrubbs 2010-08-04 bug=396419. Currently there is no
- # test api call to switchDbUser that works for non-zopeless layers.
- # When bug 396419 is fixed, we can instead use
- # DatabaseLayer.switchDbUser() instead of reconnect_stores()
- transaction.commit()
- reconnect_stores(config.statistician.dbuser)
- distroseries = getUtility(IDistroSeriesSet).get(distroseries.id)
-
- DistroSeriesPackageCache.updateAll(
- distroseries,
- archive=distroseries.distribution.main_archive,
- ztm=transaction,
- log=DevNullLogger())
- transaction.commit()
- reconnect_stores(restore_db_connection)
+ def updateDistroSeriesPackageCache(self, distroseries):
+ with dbuser(config.statistician.dbuser):
+ DistroSeriesPackageCache.updateAll(
+ distroseries,
+ archive=distroseries.distribution.main_archive,
+ ztm=transaction,
+ log=DevNullLogger())
class TestNativePublishingBase(TestCaseWithFactory, SoyuzTestPublisher):
=== removed file 'lib/lp/testing/storm.py'
--- lib/lp/testing/storm.py 2011-05-10 17:54:16 +0000
+++ lib/lp/testing/storm.py 1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
-# Copyright 2011 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-__metaclass__ = type
-__all__ = [
- 'reload_object',
- 'reload_dsp',
- ]
-
-
-from zope.security.proxy import removeSecurityProxy
-
-from canonical.launchpad.interfaces.lpstorm import IStore
-from lp.registry.model.distribution import Distribution
-
-
-def reload_object(obj):
- """Return a new instance of a storm objet from the store."""
- store = IStore(Distribution)
- return store.get(removeSecurityProxy(obj).__class__, obj.id)
-
-
-def reload_dsp(dsp):
- """Return a new instance of a DistributionSourcePackage from the store."""
- store = IStore(Distribution)
- distribution_class = removeSecurityProxy(dsp.distribution.__class__)
- distribution = store.get(distribution_class, dsp.distribution.id)
- spn_class = removeSecurityProxy(dsp.sourcepackagename.__class__)
- spn = store.get(spn_class, dsp.sourcepackagename.id)
- return distribution.getSourcePackage(name=spn.name)