Merge lp:~allenap/launchpad/bugtracker-snapshot-bug-447100 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Данило Шеган
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~allenap/launchpad/bugtracker-snapshot-bug-447100
Merge into: lp:launchpad
Diff against target: 63 lines (+20/-6)
2 files modified
lib/lp/bugs/interfaces/bugtracker.py (+6/-4)
lib/lp/bugs/tests/test_bugtracker.py (+14/-2)
To merge this branch: bzr merge lp:~allenap/launchpad/bugtracker-snapshot-bug-447100
Reviewer Review Type Date Requested Status
Данило Шеган (community) release-critical Disapprove
Aaron Bentley (community) Approve
Review via email: mp+16130@code.launchpad.net

Commit message

Prevent IBugTracker.watches from being copied into snapshots.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Uses the doNotSnapshot() decorator to prevent the 'watches' property of IBugTracker being copied into a snapshot.

Revision history for this message
Aaron Bentley (abentley) wrote :

I think "self.failUnless(getattr(original, 'watches', marker) is not marker)" is a bit redundant, since there's no way for watches to have access to a freshly-created marker.

Could you explain the import reordering to me? it's just that it seems to go against PEP8's recommendation of '1. standard library imports, 2. related third party imports, 3. local application/library specific imports'

Revision history for this message
Aaron Bentley (abentley) wrote :

As discussed on IRC:
allenap: ...I think I should put lazr.lifecycle above the lp and canonical imports.
abentley: Approved, with that change

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

As discussed on IRC, this affects only a very limited set of users (mostly Malone admins), so we'd be happy to have this on edge instead of going for an RC.

review: Disapprove (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/interfaces/bugtracker.py'
2--- lib/lp/bugs/interfaces/bugtracker.py 2009-10-02 11:29:22 +0000
3+++ lib/lp/bugs/interfaces/bugtracker.py 2009-12-23 12:34:14 +0000
4@@ -31,6 +31,7 @@
5 from canonical.launchpad.validators import LaunchpadValidationError
6 from canonical.launchpad.validators.name import name_validator
7
8+from lazr.lifecycle.snapshot import doNotSnapshot
9 from lazr.restful.declarations import (
10 export_as_webservice_entry, exported)
11 from lazr.restful.fields import CollectionField, Reference
12@@ -226,10 +227,11 @@
13 'security breach).'),
14 required=False),
15 exported_as='contact_details')
16- watches = exported(
17- CollectionField(
18- title=_('The remote watches on this bug tracker.'),
19- value_type=Reference(schema=IObject)))
20+ watches = doNotSnapshot(
21+ exported(
22+ CollectionField(
23+ title=_('The remote watches on this bug tracker.'),
24+ value_type=Reference(schema=IObject))))
25 has_lp_plugin = exported(
26 Bool(
27 title=_('This bug tracker has a Launchpad plugin installed.'),
28
29=== modified file 'lib/lp/bugs/tests/test_bugtracker.py'
30--- lib/lp/bugs/tests/test_bugtracker.py 2009-06-25 00:40:31 +0000
31+++ lib/lp/bugs/tests/test_bugtracker.py 2009-12-23 12:34:14 +0000
32@@ -8,10 +8,13 @@
33 from zope.testing.doctest import NORMALIZE_WHITESPACE, ELLIPSIS
34 from zope.testing.doctestunit import DocTestSuite
35
36+from lazr.lifecycle.snapshot import Snapshot
37+
38 from canonical.launchpad.ftests import login, ANONYMOUS
39-from lp.bugs.interfaces.bugtracker import BugTrackerType
40+from canonical.testing import LaunchpadFunctionalLayer
41+
42+from lp.bugs.interfaces.bugtracker import BugTrackerType, IBugTracker
43 from lp.testing import TestCaseWithFactory
44-from canonical.testing import LaunchpadFunctionalLayer
45
46
47 class TestBugTracker(TestCaseWithFactory):
48@@ -62,6 +65,15 @@
49 "no remote product is passed." %
50 type.title)
51
52+ def test_watches_not_in_snapshot(self):
53+ # A snapshot of an IBugTracker will not contain a copy of the
54+ # 'watches' property.
55+ marker = object()
56+ original = self.factory.makeBugTracker()
57+ self.failUnless(getattr(original, 'watches', marker) is not marker)
58+ snapshot = Snapshot(original, providing=IBugTracker)
59+ self.failUnless(getattr(snapshot, 'watches', marker) is marker)
60+
61
62 def test_suite():
63 suite = unittest.TestSuite()