← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/launchpad/bug-675426 into lp:launchpad/devel

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/bug-675426 into lp:launchpad/devel with lp:~jtv/launchpad/pre-675426 as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
  #675426 Code still using POTMsgSet.potemplate
  https://bugs.launchpad.net/bugs/675426


= 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
-- 
https://code.launchpad.net/~jtv/launchpad/bug-675426/+merge/40958
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/bug-675426 into lp:launchpad/devel.
=== 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 @@
                     "template." % id)
 
             error = self._storeTranslations(potmsgset)
-            if error and potmsgset.getSequence(potmsgset.potemplate) != 0:
+            if error and potmsgset.getSequence(self.context.potemplate) != 0:
                 # There is an error, we should store it to be rendered
                 # together with its respective view.
                 #

=== 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 @@
 
 And as it's the first entry, its sequence number is also the right one.
 
-    >>> potmsgset.getSequence(potmsgset.potemplate)
+    >>> potmsgset.getSequence(pofile_es.potemplate)
     1
 
 Test that the associated text to translate is the one we want. We initialize
@@ -215,7 +215,7 @@
 their POTMsgSets' sequence numbers.
 
     >>> for potmsgset in pofile_view._getSelectedPOTMsgSets():
-    ...     print potmsgset.getSequence(potmsgset.potemplate)
+    ...     print potmsgset.getSequence(pofile_es.potemplate)
     1
     2
     3

=== 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 @@
     1
 
 
-Ordering with unset potemplate values
--------------------------------------
-
-Fix for bug #371560: can be removed after message sharing cleanup is done.
-Code still uses potmsgset.potemplate when getting a sequence number, and
-in special case where one POTMsgSet has potemplate set (i.e. it has been
-there before message sharing work landed) and has a lower sequence number,
-and another where potemplate is not set and with a larger sequence number,
-where these appear on the same page we hit an assertion about bad sequence
-number ordering.
-
-    >>> pofile = factory.makePOFile('sr')
-    >>> potemplate = pofile.potemplate
-
-    >>> potmsgset_with_potemplate = (
-    ...     factory.makePOTMsgSet(potemplate, sequence=1))
-    >>> removeSecurityProxy(potmsgset_with_potemplate).potemplate = potemplate
-    >>> potmsgset_with_potemplate.getSequence(potemplate)
-    1
-
-    >>> potmsgset_with_no_potemplate = (
-    ...     factory.makePOTMsgSet(potemplate, sequence=2))
-    >>> print potmsgset_with_no_potemplate.potemplate
-    None
-    >>> potmsgset_with_no_potemplate.getSequence(potemplate)
-    2
-
-    # If the view internally gets a sequence using potmsgset.potemplate,
-    # which is None, we'll get a sequence of zero, which should come before
-    # sequence of 1 for the previous POTMsgSet.
-    >>> potmsgset_with_no_potemplate.getSequence(
-    ...     potmsgset_with_no_potemplate.potemplate)
-    0
-
-    >>> server_url = '/'.join(
-    ...     [canonical_url(pofile), '+translate'])
-    >>> pofile_view = create_view(
-    ...     pofile, "+translate", layer=TranslationsLayer,
-    ...     server_url=server_url)
-    >>> pofile_view.initialize()
-
-
 Sharing and diverging messages
 ------------------------------
 

=== 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 @@
 And the active translation is not the one we suggested.
 
     >>> current = potmsgset.getCurrentTranslationMessage(
-    ...     potmsgset.potemplate, spanish)
+    ...     evolution_potemplate, spanish)
     >>> current.translations
     [u'libreta de direcciones de Evolution']
 
@@ -897,7 +897,7 @@
 However, if the hoary template version is not current and thus hidden,
 we get no suggestions.
 
-    >>> potmsgset_translated.potemplate.iscurrent = False
+    >>> evo_man_template.iscurrent = False
     >>> refresh_suggestive_templates_cache()
     >>> transaction.commit()
 
@@ -912,7 +912,7 @@
 
     # We set the template as current again so we are sure that we don't show
     # suggestions just due to the change to the official_rosetta flag.
-    >>> potmsgset_translated.potemplate.iscurrent = True
+    >>> evo_man_template.iscurrent = True
     >>> ubuntu.translations_usage = ServiceUsage.NOT_APPLICABLE
     >>> refresh_suggestive_templates_cache()
     >>> transaction.commit()

=== 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 @@
 
     sequence = Attribute("The ordering of this set within its file.")
 
-    potemplate = Attribute("The template this set is associated with.")
-
     commenttext = Attribute("The manual comments this set has.")
 
     filereferences = Attribute("The files where this set appears.")

=== 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 @@
     msgid_plural = ForeignKey(foreignKey='POMsgID', dbName='msgid_plural',
         notNull=False, default=DEFAULT)
     sequence = IntCol(dbName='sequence')
-    potemplate = ForeignKey(foreignKey='POTemplate', dbName='potemplate')
     commenttext = StringCol(dbName='commenttext', notNull=False)
     filereferences = StringCol(dbName='filereferences', notNull=False)
     sourcecomment = StringCol(dbName='sourcecomment', notNull=False)
@@ -905,7 +904,7 @@
         """See `IPOTMsgSet`."""
         assert(lock_timestamp is not None)
         current = self.getCurrentTranslationMessage(
-            self.potemplate, pofile.language)
+            pofile.potemplate, pofile.language)
         if current is None:
             # Create an empty translation message.
             current = self.updateTranslation(