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
=== modified file 'lib/lp/translations/browser/pofile.py'
--- lib/lp/translations/browser/pofile.py 2010-11-05 14:17:11 +0000
+++ lib/lp/translations/browser/pofile.py 2010-11-16 13:55:24 +0000
@@ -854,7 +854,7 @@
854 "template." % id)854 "template." % id)
855855
856 error = self._storeTranslations(potmsgset)856 error = self._storeTranslations(potmsgset)
857 if error and potmsgset.getSequence(potmsgset.potemplate) != 0:857 if error and potmsgset.getSequence(self.context.potemplate) != 0:
858 # There is an error, we should store it to be rendered858 # There is an error, we should store it to be rendered
859 # together with its respective view.859 # together with its respective view.
860 #860 #
861861
=== modified file 'lib/lp/translations/browser/tests/pofile-views.txt'
--- lib/lp/translations/browser/tests/pofile-views.txt 2010-10-18 22:24:59 +0000
+++ lib/lp/translations/browser/tests/pofile-views.txt 2010-11-16 13:55:24 +0000
@@ -116,7 +116,7 @@
116116
117And as it's the first entry, its sequence number is also the right one.117And as it's the first entry, its sequence number is also the right one.
118118
119 >>> potmsgset.getSequence(potmsgset.potemplate)119 >>> potmsgset.getSequence(pofile_es.potemplate)
120 1120 1
121121
122Test that the associated text to translate is the one we want. We initialize122Test that the associated text to translate is the one we want. We initialize
@@ -215,7 +215,7 @@
215their POTMsgSets' sequence numbers.215their POTMsgSets' sequence numbers.
216216
217 >>> for potmsgset in pofile_view._getSelectedPOTMsgSets():217 >>> for potmsgset in pofile_view._getSelectedPOTMsgSets():
218 ... print potmsgset.getSequence(potmsgset.potemplate)218 ... print potmsgset.getSequence(pofile_es.potemplate)
219 1219 1
220 2220 2
221 3221 3
222222
=== modified file 'lib/lp/translations/browser/tests/translationmessage-views.txt'
--- lib/lp/translations/browser/tests/translationmessage-views.txt 2010-11-05 14:56:34 +0000
+++ lib/lp/translations/browser/tests/translationmessage-views.txt 2010-11-16 13:55:24 +0000
@@ -565,48 +565,6 @@
565 1565 1
566566
567567
568Ordering with unset potemplate values
569-------------------------------------
570
571Fix for bug #371560: can be removed after message sharing cleanup is done.
572Code still uses potmsgset.potemplate when getting a sequence number, and
573in special case where one POTMsgSet has potemplate set (i.e. it has been
574there before message sharing work landed) and has a lower sequence number,
575and another where potemplate is not set and with a larger sequence number,
576where these appear on the same page we hit an assertion about bad sequence
577number ordering.
578
579 >>> pofile = factory.makePOFile('sr')
580 >>> potemplate = pofile.potemplate
581
582 >>> potmsgset_with_potemplate = (
583 ... factory.makePOTMsgSet(potemplate, sequence=1))
584 >>> removeSecurityProxy(potmsgset_with_potemplate).potemplate = potemplate
585 >>> potmsgset_with_potemplate.getSequence(potemplate)
586 1
587
588 >>> potmsgset_with_no_potemplate = (
589 ... factory.makePOTMsgSet(potemplate, sequence=2))
590 >>> print potmsgset_with_no_potemplate.potemplate
591 None
592 >>> potmsgset_with_no_potemplate.getSequence(potemplate)
593 2
594
595 # If the view internally gets a sequence using potmsgset.potemplate,
596 # which is None, we'll get a sequence of zero, which should come before
597 # sequence of 1 for the previous POTMsgSet.
598 >>> potmsgset_with_no_potemplate.getSequence(
599 ... potmsgset_with_no_potemplate.potemplate)
600 0
601
602 >>> server_url = '/'.join(
603 ... [canonical_url(pofile), '+translate'])
604 >>> pofile_view = create_view(
605 ... pofile, "+translate", layer=TranslationsLayer,
606 ... server_url=server_url)
607 >>> pofile_view.initialize()
608
609
610Sharing and diverging messages568Sharing and diverging messages
611------------------------------569------------------------------
612570
613571
=== modified file 'lib/lp/translations/doc/potmsgset.txt'
--- lib/lp/translations/doc/potmsgset.txt 2010-10-29 18:45:22 +0000
+++ lib/lp/translations/doc/potmsgset.txt 2010-11-16 13:55:24 +0000
@@ -416,7 +416,7 @@
416And the active translation is not the one we suggested.416And the active translation is not the one we suggested.
417417
418 >>> current = potmsgset.getCurrentTranslationMessage(418 >>> current = potmsgset.getCurrentTranslationMessage(
419 ... potmsgset.potemplate, spanish)419 ... evolution_potemplate, spanish)
420 >>> current.translations420 >>> current.translations
421 [u'libreta de direcciones de Evolution']421 [u'libreta de direcciones de Evolution']
422422
@@ -897,7 +897,7 @@
897However, if the hoary template version is not current and thus hidden,897However, if the hoary template version is not current and thus hidden,
898we get no suggestions.898we get no suggestions.
899899
900 >>> potmsgset_translated.potemplate.iscurrent = False900 >>> evo_man_template.iscurrent = False
901 >>> refresh_suggestive_templates_cache()901 >>> refresh_suggestive_templates_cache()
902 >>> transaction.commit()902 >>> transaction.commit()
903903
@@ -912,7 +912,7 @@
912912
913 # We set the template as current again so we are sure that we don't show913 # We set the template as current again so we are sure that we don't show
914 # suggestions just due to the change to the official_rosetta flag.914 # suggestions just due to the change to the official_rosetta flag.
915 >>> potmsgset_translated.potemplate.iscurrent = True915 >>> evo_man_template.iscurrent = True
916 >>> ubuntu.translations_usage = ServiceUsage.NOT_APPLICABLE916 >>> ubuntu.translations_usage = ServiceUsage.NOT_APPLICABLE
917 >>> refresh_suggestive_templates_cache()917 >>> refresh_suggestive_templates_cache()
918 >>> transaction.commit()918 >>> transaction.commit()
919919
=== modified file 'lib/lp/translations/interfaces/potmsgset.py'
--- lib/lp/translations/interfaces/potmsgset.py 2010-10-27 18:30:31 +0000
+++ lib/lp/translations/interfaces/potmsgset.py 2010-11-16 13:55:24 +0000
@@ -102,8 +102,6 @@
102102
103 sequence = Attribute("The ordering of this set within its file.")103 sequence = Attribute("The ordering of this set within its file.")
104104
105 potemplate = Attribute("The template this set is associated with.")
106
107 commenttext = Attribute("The manual comments this set has.")105 commenttext = Attribute("The manual comments this set has.")
108106
109 filereferences = Attribute("The files where this set appears.")107 filereferences = Attribute("The files where this set appears.")
110108
=== modified file 'lib/lp/translations/model/potmsgset.py'
--- lib/lp/translations/model/potmsgset.py 2010-11-11 09:41:28 +0000
+++ lib/lp/translations/model/potmsgset.py 2010-11-16 13:55:24 +0000
@@ -108,7 +108,6 @@
108 msgid_plural = ForeignKey(foreignKey='POMsgID', dbName='msgid_plural',108 msgid_plural = ForeignKey(foreignKey='POMsgID', dbName='msgid_plural',
109 notNull=False, default=DEFAULT)109 notNull=False, default=DEFAULT)
110 sequence = IntCol(dbName='sequence')110 sequence = IntCol(dbName='sequence')
111 potemplate = ForeignKey(foreignKey='POTemplate', dbName='potemplate')
112 commenttext = StringCol(dbName='commenttext', notNull=False)111 commenttext = StringCol(dbName='commenttext', notNull=False)
113 filereferences = StringCol(dbName='filereferences', notNull=False)112 filereferences = StringCol(dbName='filereferences', notNull=False)
114 sourcecomment = StringCol(dbName='sourcecomment', notNull=False)113 sourcecomment = StringCol(dbName='sourcecomment', notNull=False)
@@ -905,7 +904,7 @@
905 """See `IPOTMsgSet`."""904 """See `IPOTMsgSet`."""
906 assert(lock_timestamp is not None)905 assert(lock_timestamp is not None)
907 current = self.getCurrentTranslationMessage(906 current = self.getCurrentTranslationMessage(
908 self.potemplate, pofile.language)907 pofile.potemplate, pofile.language)
909 if current is None:908 if current is None:
910 # Create an empty translation message.909 # Create an empty translation message.
911 current = self.updateTranslation(910 current = self.updateTranslation(