Merge lp:~stevenk/launchpad/one-linkcve into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 15693
Proposed branch: lp:~stevenk/launchpad/one-linkcve
Merge into: lp:launchpad
Diff against target: 72 lines (+6/-21)
3 files modified
lib/lp/_schema_circular_imports.py (+1/-1)
lib/lp/bugs/interfaces/bug.py (+2/-11)
lib/lp/bugs/model/bug.py (+3/-9)
To merge this branch: bzr merge lp:~stevenk/launchpad/one-linkcve
Reviewer Review Type Date Requested Status
Ian Booth (community) Approve
Review via email: mp+116582@code.launchpad.net

Commit message

Delete IBug.linkCVEAndReturnNothing and make use of a new argument to linkCVE to not return the linked CVE.

Description of the change

Delete IBug.linkCVEAndReturnNothing for being dreadful. Sadly, it was exported as IBug.linkCVE() over the API, so I've moved the decorators to linkCVE() and given it a new option that tells whether to return the CVE or not.

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/_schema_circular_imports.py'
2--- lib/lp/_schema_circular_imports.py 2012-07-04 17:02:34 +0000
3+++ lib/lp/_schema_circular_imports.py 2012-07-25 04:54:21 +0000
4@@ -795,7 +795,7 @@
5 IBug, 'beta', "addAttachment", "addNomination", "addTask", "addWatch",
6 "canBeNominatedFor", "getHWSubmissions", "getNominationFor",
7 "getNominations", "isExpirable", "isUserAffected",
8- "linkCVEAndReturnNothing", "linkHWSubmission", "markAsDuplicate",
9+ "linkCVE", "linkHWSubmission", "markAsDuplicate",
10 "markUserAffected", "newMessage", "setCommentVisibility", "setPrivate",
11 "setSecurityRelated", "subscribe", "unlinkCVE", "unlinkHWSubmission",
12 "unsubscribe", "unsubscribeFromDupes")
13
14=== modified file 'lib/lp/bugs/interfaces/bug.py'
15--- lib/lp/bugs/interfaces/bug.py 2012-06-19 02:14:21 +0000
16+++ lib/lp/bugs/interfaces/bug.py 2012-07-25 04:54:21 +0000
17@@ -31,7 +31,6 @@
18 call_with,
19 export_as_webservice_entry,
20 export_factory_operation,
21- export_operation_as,
22 export_read_operation,
23 export_write_operation,
24 exported,
25@@ -837,18 +836,10 @@
26 file_alias.restricted.
27 """
28
29- def linkCVE(cve, user):
30- """Ensure that this CVE is linked to this bug."""
31-
32- # XXX intellectronica 2008-11-06 Bug #294858:
33- # We use this method to suppress the return value
34- # from linkCVE, which we don't want to export.
35- # In the future we'll have a decorator which does that for us.
36- @call_with(user=REQUEST_USER)
37+ @call_with(user=REQUEST_USER, returncve=False)
38 @operation_parameters(cve=Reference(ICve, title=_('CVE'), required=True))
39- @export_operation_as('linkCVE')
40 @export_write_operation()
41- def linkCVEAndReturnNothing(cve, user):
42+ def linkCVE(cve, user, returncve=True):
43 """Ensure that this CVE is linked to this bug."""
44
45 @call_with(user=REQUEST_USER)
46
47=== modified file 'lib/lp/bugs/model/bug.py'
48--- lib/lp/bugs/model/bug.py 2012-07-19 04:40:03 +0000
49+++ lib/lp/bugs/model/bug.py 2012-07-25 04:54:21 +0000
50@@ -1386,19 +1386,13 @@
51 """See `IBug`."""
52 return bool(self.cves)
53
54- def linkCVE(self, cve, user):
55+ def linkCVE(self, cve, user, returncve=True):
56 """See `IBug`."""
57 if cve not in self.cves:
58 bugcve = BugCve(bug=self, cve=cve)
59 notify(ObjectCreatedEvent(bugcve, user=user))
60- return bugcve
61-
62- # XXX intellectronica 2008-11-06 Bug #294858:
63- # See lp.bugs.interfaces.bug
64- def linkCVEAndReturnNothing(self, cve, user):
65- """See `IBug`."""
66- self.linkCVE(cve, user)
67- return None
68+ if returncve:
69+ return bugcve
70
71 def unlinkCVE(self, cve, user):
72 """See `IBug`."""