Merge lp:~jcsackett/launchpad/deprecate-official_malone into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Edwin Grubbs on 2010-08-26 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11493 |
| Proposed branch: | lp:~jcsackett/launchpad/deprecate-official_malone |
| Merge into: | lp:launchpad |
| Diff against target: |
979 lines (+148/-116) 25 files modified
lib/canonical/launchpad/doc/vocabularies.txt (+3/-3) lib/canonical/launchpad/vocabularies/dbobjects.py (+8/-6) lib/lp/bugs/browser/bugalsoaffects.py (+6/-4) lib/lp/bugs/browser/bugtarget.py (+12/-7) lib/lp/bugs/browser/bugtask.py (+24/-22) lib/lp/bugs/browser/distribution_upstream_bug_report.py (+13/-8) lib/lp/bugs/browser/tests/bugtask-adding-views.txt (+6/-6) lib/lp/bugs/browser/tests/test_bugtarget_configure.py (+4/-1) lib/lp/bugs/model/bug.py (+2/-1) lib/lp/bugs/model/bugtask.py (+10/-7) lib/lp/bugs/templates/bug-create-question.pt (+1/-1) lib/lp/bugs/templates/bugtarget-macros-filebug.pt (+1/-1) lib/lp/bugs/templates/bugtask-requestfix-upstream.pt (+3/-3) lib/lp/bugs/templates/distribution-upstream-bug-report.pt (+6/-4) lib/lp/bugs/tests/bugtarget-questiontarget.txt (+4/-4) lib/lp/bugs/tests/test_bugs_webservice.py (+20/-12) lib/lp/bugs/tests/test_bugtask_1.py (+8/-9) lib/lp/registry/browser/sourcepackage.py (+5/-5) lib/lp/registry/browser/tests/distribution-views.txt (+4/-4) lib/lp/registry/browser/tests/sourcepackage-views.txt (+2/-2) lib/lp/registry/doc/product.txt (+2/-2) lib/lp/registry/templates/distribution-index.pt (+1/-1) lib/lp/registry/templates/distribution-search.pt (+1/-1) lib/lp/registry/templates/product-index.pt (+1/-1) lib/lp/testing/factory.py (+1/-1) |
| To merge this branch: | bzr merge lp:~jcsackett/launchpad/deprecate-official_malone |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Edwin Grubbs (community) | code | 2010-08-25 | Approve on 2010-08-26 |
|
Review via email:
|
|||
Commit Message
Deprecates usage of official_malone where possible in favor of bug_tracking_usage.
Description of the Change
= Summary =
Replaces, where possible, usage of official_malone with the bug_tracking_usage property.
== Proposed fix ==
Where code uses official_malone to drive a decision regarding presentation or action,
update the code to use bug_tracking_usage instead, so we can use the richer data
provided by the usage enums.
== Pre-implementation notes ==
Spoke with Curtis Hovey (sinzui) and Brad Crittenden (bac).
== Implementation details ==
As in Proposed fix.
SQL queries using official_malone have been left alone until data migration occurs.
Instances where an assignment is made to official_malone, no replacement is made as the official_malone
boolean is part of the data driving bug_tracking_usage.
== Tests ==
No new tests written.
To fully test the refactor:
bin/test -m lib.lp.registry
bin/test -m lib.lp.bugs
== Demo and Q/A ==
In Launchpad.dev, nothing should crash when reviewing bugs or performing bug related actions.
There are no changes to the UX or UI, I believe everything should function in the same fashion.
= Launchpad lint =
This touched enough old files that the lint output is huge. I will fix all valid lint errors before committing, but I didn't want to pollute the diff too much nor make this MP a wall of text.
| j.c.sackett (jcsackett) wrote : | # |
| Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi JC,
This does not look like a fun branch, but it is very helpful. I have a
few questions and suggestions below.
-Edwin
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -56,6 +56,7 @@
> from canonical.
> from canonical.
> from canonical.
>+from lp.app.enums import ServiceUsage
> from lp.bugs.
> from lp.bugs.
> BugTaskImportance,
>@@ -319,10 +320,11 @@
> if bug_watch is None:
> bug_watch = task_added.
> extracted_
>- if not target.
>+ if target.
> task_added.bugwatch = bug_watch
>
>- if (not target.
>+ if (target.
Whitespace at end of line.
>+ and task_added.bugwatch is not None
> and (task_added.
> BugTrackerType.
> # A remote bug task gets its status from a bug watch, so
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -96,7 +96,11 @@
> NotFoundError,
> UnexpectedFormData,
> )
>-from lp.app.
>+from lp.app.enums import ServiceUsage
lp.app.enums should be placed above lp.app.errors.
>+from lp.app.
>+ ILaunchpadUsage,
>+ IServiceUsage,
>+ )
> from lp.bugs.
> from lp.bugs.
> from lp.bugs.
>@@ -384,7 +388,7 @@
> # actually uses Malone for its bug tracking.
> product_or_distro = self.getProduct
> if (product_or_distro is not None and
>- not product_
>+ product_
> self.setFieldError(
> 'bugtarget',
> "%s does not use Launchpad as its bug tracker " %
>@@ -426,10 +430,11 @@
> if IProjectGroup.
> products_
> product for product in self.context.
>- if product.
>+ if product.
> return len(products_
> else:
>- return self.getMainCon
>+ bug_tracking_usage = self.getMainCon
>+ return bug_tracking_usage == ServiceUsage.
Does this mean that Projec...
| j.c.sackett (jcsackett) wrote : | # |
Updated diff:
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -323,7 +323,7 @@
if target.
- if (target.
+ if (target.
and task_added.bugwatch is not None
and (task_added.
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -92,11 +92,11 @@
GhostWidget,
ProductBug
)
+from lp.app.enums import ServiceUsage
from lp.app.errors import (
NotFoundError,
Unexpected
)
-from lp.app.enums import ServiceUsage
from lp.app.
ILaunchpad
IServiceUsage,
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -146,7 +146,7 @@
- dssp: an IDistributionSe
- product: an IProduct
- bugtracker: convenience holder for the product's bugtracker
- - bug_tracking_usage: convenience enum for
+ - bug_tracking_usage: convenience enum for
- *_url: convenience URLs
"""
@@ -166,6 +166,7 @@
+ # If a product is specified, build some convenient links to
# pages which allow filling out required information. The
# template ensures they are only visible to people who can
# actually change the product.
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -166,10 +166,12 @@
- <td tal:condition=
+ <td tal:condition=
+ align="center">
- <td tal:condition="not: item/bug_
+ <td tal:condition="not: item/bug_
+ align="center">
| j.c.sackett (jcsackett) wrote : | # |
>> + if (target.
>
>
> Whitespace at end of line.
Taken care of.
>> -from lp.app.
>> +from lp.app.enums import ServiceUsage
>
>
> lp.app.enums should be placed above lp.app.errors.
Agreed, and done.
>> @@ -426,10 +430,11 @@
>> if IProjectGroup.
>> products_
>> product for product in self.context.
>> - if product.
>> + if product.
>> return len(products_
>> else:
>> - return self.getMainCon
>> + bug_tracking_usage = self.getMainCon
>> + return bug_tracking_usage == ServiceUsage.
>
>
>
> Does this mean that ProjectGroup will never implement IServiceUsage?
This may be ignorance of a better solution on my part, but as ProjectGroup didn't implement ILaunchpadUsage
(where the official_* attrs are largely defined) I didn't think it needed to implement IServiceUsage; at least not
within the scope of this branch. The mods above get to the usage_enum in the same way that the official_bool
was retrieved.
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -193,6 +193,7 @@
>> )
>> from canonical.
>> from lp.answers.
>> +from lp.app.enums import ServiceUsage
>> from lp.app.errors import (
>> NotFoundError,
>> UnexpectedFormData,
>> @@ -1668,7 +1669,7 @@
>>
>> new_product = data.get('product')
>> if (old_product is None or old_product == new_product or
>> - not bugtask.
>> + bugtask.
>> # Either the product wasn't changed, we're dealing with a #
>> # distro task, or the bugtask's product doesn't use Launchpad,
>> # which means the product can't be changed.
>
>
> The comment and the the if-statement don't make sense. Why would we
> care if the current bugtask.pillar doesn't use LP Bugs? It should check
> if the new_product uses LP Bugs. Can you ask the bugs team about this?
According to deryck, that's because it's checking the bugtask target, which may not actually be
old_ or new_ product and may be a distro.
There was some confusion on this point; I believe jml and deryck are still
looking into it, but seemed to believe it was correct.
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -17,6 +17,7 @@
>> LaunchpadView,
>> )
>> from canonical.
>> +from lp.app.enums import ServiceUsage
>> from lp.bugs.
| Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi JC,
Thanks for making the changes. I just have one more item that should be changed before this lands.
-Edwin
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -26,14 +34,12 @@
> )
>
>
> +@implementer(
> +@adapter(
> def distroseries_
> """Adapts `IDistroSeries` object to `ILaunchpadUsag
> return distroseries.
>
> -def distroseries_
> - """Adapts `IDistroSeries` object to `IServiceUsage`."""
> - return distroseries.
> -
> def person_
> """Adapt `ILaunchpadPrin
> if ILaunchpadPrinc
I like that you are trying to reuse the function, but I think it will confuse someone horribly if @implementer doesn't match the function name or the docstring. You might be able to get this to work with:
@implementer(
and then the function name should be changed to distroseries_
If this doesn't work easily, just add the old function back and put @implementer and @adapter above that.

I've noticed that the diff gets weird over time, so I'm snapshotting it near the beginning of this MP.
=== modified file 'lib/canonical/ launchpad/ doc/vocabularie s.txt' launchpad/ doc/vocabularie s.txt 2010-02-17 11:13:06 +0000 launchpad/ doc/vocabularie s.txt 2010-08-25 14:36:51 +0000
--- lib/canonical/
+++ lib/canonical/
@@ -251,9 +251,9 @@
>>> mozilla_project = getUtility( IProjectGroupSe t).getByName( 'mozilla' ) project. products: official_ malone) bug_tracking_ usage.name)
>>> for product in mozilla_
- ... print "%s: %s" % (product.name, product.
- firefox: True
- thunderbird: False
+ ... print "%s: %s" % (product.name, product.
+ firefox: LAUNCHPAD
+ thunderbird: UNKNOWN
>>> mozilla_ products_ vocabulary = vocabulary_ registry. get( project, 'ProjectProduct sUsingMalone' )
... mozilla_
=== modified file 'lib/canonical/ launchpad/ vocabularies/ dbobjects. py' launchpad/ vocabularies/ dbobjects. py 2010-08-20 20:31:18 +0000 launchpad/ vocabularies/ dbobjects. py 2010-08-25 20:17:12 +0000 ocabularyBase, browser. stringformatter import FormattersAPI interfaces. specification import SpecificationFilter model.specifica tion import Specification model.sprint import Sprint
super( HostedBranchRes trictedOnOwnerV ocabulary, self)._ _init__ (context)
--- lib/canonical/
+++ lib/canonical/
@@ -87,6 +87,7 @@
SQLObjectV
)
from lp.app.
+from lp.app.enums import ServiceUsage
from lp.blueprints.
from lp.blueprints.
from lp.blueprints.
@@ -234,6 +235,7 @@
These are branches that the user is guaranteed to be able to push
to.
"""
+
def __init__(self, context=None):
"""Pass a Person as context, or anything else for the current user."""
@@ -341,6 +343,7 @@
This vocabulary contains all the languages known to Launchpad,
excluding English and non-visible languages.
"""
+
def __contains__(self, language):
"""See `IVocabulary`.
@@ -382,7 +385,7 @@
SimpleTerm( product, product.name, title=product. displayname) official_ malone] ) bug_tracking_ usage == ServiceUsage. LAUNCHPAD] )
return SimpleVocabulary([
for product in project.products
- if product.
+ if product.
class TranslationGrou pVocabulary( NamedSQLObjectV ocabulary) : selectBy( official_ malone= True).count( )
@@ -741,7 +744,8 @@
return Distribution.
def __contains__(self, obj): providedBy( obj) and obj.official_malone providedBy( obj) tracking_ usage == ServiceUsage. LAUNCHPAD)
- return IDistribution.
+ return (IDistribution.
+ and obj.bug_
def getQuery(self):
return None
=== modified file 'lib/lp/ bugs/browser/ bugalsoaffects. py' bugs/browser/ bugalsoaffects. py 2010-08-20 20:31:18 +0000 bugs/browser/ bugalsoaffects. py 2010-08-25 15:55:41 +0000 widgets. itemswidgets import LaunchpadRadioW idget widgets. popup import SearchForUpstre amPopupWidget widgets. textwidgets import StrippedTextWidget interfaces. bug import IBug interfaces. bugtask import ( ortance,
--- lib/lp/
+++ lib/lp/
@@ -56,6 +56,7 @@
from canonical.
from canonical.
from canonical.
+from lp.app.enums import ServiceUsage
from lp.bugs.
from lp.bugs.
BugTaskImp
@@ -319,10 +320,11 @@
...