Merge lp:~jtv/launchpad/bug-675426 into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 11929
Proposed branch: lp:~jtv/launchpad/bug-675426
Merge into: lp:launchpad
Prerequisite: lp:~jtv/launchpad/pre-675426
Diff against target: 152 lines (+7/-52)
6 files modified
lib/lp/translations/browser/pofile.py (+1/-1)
lib/lp/translations/browser/tests/pofile-views.txt (+2/-2)
lib/lp/translations/browser/tests/translationmessage-views.txt (+0/-42)
lib/lp/translations/doc/potmsgset.txt (+3/-3)
lib/lp/translations/interfaces/potmsgset.py (+0/-2)
lib/lp/translations/model/potmsgset.py (+1/-2)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-675426
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+40958@code.launchpad.net

Commit message

[r=gmb][ui=none][bug=675426] Remove [I]POTMsgSet.potemplate.

Description of the change

= Bug 675426 =

We're still referencing POTMsgSet.potemplate in a few places, though it's supposed to be obsolete. After removing a lot of dead code, it's next to nothing.

This branch removes all the remaining uses I could find, as well as the interface and model-class attributes. There may be more references hidden away in SQL, but if so we'll have to find those when we remove the column from the database schema.

To test,
{{{
./bin/test -vvc lp.translations.tests
}}}

The only way to Q/A this is to wait for oopses—not that there should be any.

No lint,

Jeroen

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/browser/pofile.py'
2--- lib/lp/translations/browser/pofile.py 2010-11-05 14:17:11 +0000
3+++ lib/lp/translations/browser/pofile.py 2010-11-16 13:55:24 +0000
4@@ -854,7 +854,7 @@
5 "template." % id)
6
7 error = self._storeTranslations(potmsgset)
8- if error and potmsgset.getSequence(potmsgset.potemplate) != 0:
9+ if error and potmsgset.getSequence(self.context.potemplate) != 0:
10 # There is an error, we should store it to be rendered
11 # together with its respective view.
12 #
13
14=== modified file 'lib/lp/translations/browser/tests/pofile-views.txt'
15--- lib/lp/translations/browser/tests/pofile-views.txt 2010-10-18 22:24:59 +0000
16+++ lib/lp/translations/browser/tests/pofile-views.txt 2010-11-16 13:55:24 +0000
17@@ -116,7 +116,7 @@
18
19 And as it's the first entry, its sequence number is also the right one.
20
21- >>> potmsgset.getSequence(potmsgset.potemplate)
22+ >>> potmsgset.getSequence(pofile_es.potemplate)
23 1
24
25 Test that the associated text to translate is the one we want. We initialize
26@@ -215,7 +215,7 @@
27 their POTMsgSets' sequence numbers.
28
29 >>> for potmsgset in pofile_view._getSelectedPOTMsgSets():
30- ... print potmsgset.getSequence(potmsgset.potemplate)
31+ ... print potmsgset.getSequence(pofile_es.potemplate)
32 1
33 2
34 3
35
36=== modified file 'lib/lp/translations/browser/tests/translationmessage-views.txt'
37--- lib/lp/translations/browser/tests/translationmessage-views.txt 2010-11-05 14:56:34 +0000
38+++ lib/lp/translations/browser/tests/translationmessage-views.txt 2010-11-16 13:55:24 +0000
39@@ -565,48 +565,6 @@
40 1
41
42
43-Ordering with unset potemplate values
44--------------------------------------
45-
46-Fix for bug #371560: can be removed after message sharing cleanup is done.
47-Code still uses potmsgset.potemplate when getting a sequence number, and
48-in special case where one POTMsgSet has potemplate set (i.e. it has been
49-there before message sharing work landed) and has a lower sequence number,
50-and another where potemplate is not set and with a larger sequence number,
51-where these appear on the same page we hit an assertion about bad sequence
52-number ordering.
53-
54- >>> pofile = factory.makePOFile('sr')
55- >>> potemplate = pofile.potemplate
56-
57- >>> potmsgset_with_potemplate = (
58- ... factory.makePOTMsgSet(potemplate, sequence=1))
59- >>> removeSecurityProxy(potmsgset_with_potemplate).potemplate = potemplate
60- >>> potmsgset_with_potemplate.getSequence(potemplate)
61- 1
62-
63- >>> potmsgset_with_no_potemplate = (
64- ... factory.makePOTMsgSet(potemplate, sequence=2))
65- >>> print potmsgset_with_no_potemplate.potemplate
66- None
67- >>> potmsgset_with_no_potemplate.getSequence(potemplate)
68- 2
69-
70- # If the view internally gets a sequence using potmsgset.potemplate,
71- # which is None, we'll get a sequence of zero, which should come before
72- # sequence of 1 for the previous POTMsgSet.
73- >>> potmsgset_with_no_potemplate.getSequence(
74- ... potmsgset_with_no_potemplate.potemplate)
75- 0
76-
77- >>> server_url = '/'.join(
78- ... [canonical_url(pofile), '+translate'])
79- >>> pofile_view = create_view(
80- ... pofile, "+translate", layer=TranslationsLayer,
81- ... server_url=server_url)
82- >>> pofile_view.initialize()
83-
84-
85 Sharing and diverging messages
86 ------------------------------
87
88
89=== modified file 'lib/lp/translations/doc/potmsgset.txt'
90--- lib/lp/translations/doc/potmsgset.txt 2010-10-29 18:45:22 +0000
91+++ lib/lp/translations/doc/potmsgset.txt 2010-11-16 13:55:24 +0000
92@@ -416,7 +416,7 @@
93 And the active translation is not the one we suggested.
94
95 >>> current = potmsgset.getCurrentTranslationMessage(
96- ... potmsgset.potemplate, spanish)
97+ ... evolution_potemplate, spanish)
98 >>> current.translations
99 [u'libreta de direcciones de Evolution']
100
101@@ -897,7 +897,7 @@
102 However, if the hoary template version is not current and thus hidden,
103 we get no suggestions.
104
105- >>> potmsgset_translated.potemplate.iscurrent = False
106+ >>> evo_man_template.iscurrent = False
107 >>> refresh_suggestive_templates_cache()
108 >>> transaction.commit()
109
110@@ -912,7 +912,7 @@
111
112 # We set the template as current again so we are sure that we don't show
113 # suggestions just due to the change to the official_rosetta flag.
114- >>> potmsgset_translated.potemplate.iscurrent = True
115+ >>> evo_man_template.iscurrent = True
116 >>> ubuntu.translations_usage = ServiceUsage.NOT_APPLICABLE
117 >>> refresh_suggestive_templates_cache()
118 >>> transaction.commit()
119
120=== modified file 'lib/lp/translations/interfaces/potmsgset.py'
121--- lib/lp/translations/interfaces/potmsgset.py 2010-10-27 18:30:31 +0000
122+++ lib/lp/translations/interfaces/potmsgset.py 2010-11-16 13:55:24 +0000
123@@ -102,8 +102,6 @@
124
125 sequence = Attribute("The ordering of this set within its file.")
126
127- potemplate = Attribute("The template this set is associated with.")
128-
129 commenttext = Attribute("The manual comments this set has.")
130
131 filereferences = Attribute("The files where this set appears.")
132
133=== modified file 'lib/lp/translations/model/potmsgset.py'
134--- lib/lp/translations/model/potmsgset.py 2010-11-11 09:41:28 +0000
135+++ lib/lp/translations/model/potmsgset.py 2010-11-16 13:55:24 +0000
136@@ -108,7 +108,6 @@
137 msgid_plural = ForeignKey(foreignKey='POMsgID', dbName='msgid_plural',
138 notNull=False, default=DEFAULT)
139 sequence = IntCol(dbName='sequence')
140- potemplate = ForeignKey(foreignKey='POTemplate', dbName='potemplate')
141 commenttext = StringCol(dbName='commenttext', notNull=False)
142 filereferences = StringCol(dbName='filereferences', notNull=False)
143 sourcecomment = StringCol(dbName='sourcecomment', notNull=False)
144@@ -905,7 +904,7 @@
145 """See `IPOTMsgSet`."""
146 assert(lock_timestamp is not None)
147 current = self.getCurrentTranslationMessage(
148- self.potemplate, pofile.language)
149+ pofile.potemplate, pofile.language)
150 if current is None:
151 # Create an empty translation message.
152 current = self.updateTranslation(