← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/one-linkcve into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/one-linkcve/+merge/116582

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.
-- 
https://code.launchpad.net/~stevenk/launchpad/one-linkcve/+merge/116582
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/one-linkcve into lp:launchpad.
=== modified file 'lib/lp/_schema_circular_imports.py'
--- lib/lp/_schema_circular_imports.py	2012-07-04 17:02:34 +0000
+++ lib/lp/_schema_circular_imports.py	2012-07-25 04:47:19 +0000
@@ -795,7 +795,7 @@
     IBug, 'beta', "addAttachment", "addNomination", "addTask", "addWatch",
     "canBeNominatedFor", "getHWSubmissions", "getNominationFor",
     "getNominations", "isExpirable", "isUserAffected",
-    "linkCVEAndReturnNothing", "linkHWSubmission", "markAsDuplicate",
+    "linkCVE", "linkHWSubmission", "markAsDuplicate",
     "markUserAffected", "newMessage", "setCommentVisibility", "setPrivate",
     "setSecurityRelated", "subscribe", "unlinkCVE", "unlinkHWSubmission",
     "unsubscribe", "unsubscribeFromDupes")

=== modified file 'lib/lp/bugs/interfaces/bug.py'
--- lib/lp/bugs/interfaces/bug.py	2012-06-19 02:14:21 +0000
+++ lib/lp/bugs/interfaces/bug.py	2012-07-25 04:47:19 +0000
@@ -837,18 +837,11 @@
         file_alias.restricted.
         """
 
-    def linkCVE(cve, user):
-        """Ensure that this CVE is linked to this bug."""
-
-    # XXX intellectronica 2008-11-06 Bug #294858:
-    # We use this method to suppress the return value
-    # from linkCVE, which we don't want to export.
-    # In the future we'll have a decorator which does that for us.
-    @call_with(user=REQUEST_USER)
+    @call_with(user=REQUEST_USER, returncve=False)
     @operation_parameters(cve=Reference(ICve, title=_('CVE'), required=True))
     @export_operation_as('linkCVE')
     @export_write_operation()
-    def linkCVEAndReturnNothing(cve, user):
+    def linkCVE(cve, user, returncve=True):
         """Ensure that this CVE is linked to this bug."""
 
     @call_with(user=REQUEST_USER)

=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py	2012-07-19 04:40:03 +0000
+++ lib/lp/bugs/model/bug.py	2012-07-25 04:47:19 +0000
@@ -1386,19 +1386,13 @@
         """See `IBug`."""
         return bool(self.cves)
 
-    def linkCVE(self, cve, user):
+    def linkCVE(self, cve, user, returncve=True):
         """See `IBug`."""
         if cve not in self.cves:
             bugcve = BugCve(bug=self, cve=cve)
             notify(ObjectCreatedEvent(bugcve, user=user))
-            return bugcve
-
-    # XXX intellectronica 2008-11-06 Bug #294858:
-    # See lp.bugs.interfaces.bug
-    def linkCVEAndReturnNothing(self, cve, user):
-        """See `IBug`."""
-        self.linkCVE(cve, user)
-        return None
+            if returncve:
+                return bugcve
 
     def unlinkCVE(self, cve, user):
         """See `IBug`."""


Follow ups