Merge lp:~jtv/launchpad/recife-new-resetcurrenttranslation into lp:~launchpad/launchpad/recife
| Status: | Merged |
|---|---|
| Approved by: | Michael Nelson on 2010-08-26 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 9164 |
| Proposed branch: | lp:~jtv/launchpad/recife-new-resetcurrenttranslation |
| Merge into: | lp:~launchpad/launchpad/recife |
| Diff against target: |
406 lines (+188/-90) 4 files modified
lib/lp/translations/browser/translationmessage.py (+15/-16) lib/lp/translations/interfaces/potmsgset.py (+23/-10) lib/lp/translations/model/potmsgset.py (+39/-17) lib/lp/translations/tests/test_potmsgset.py (+111/-47) |
| To merge this branch: | bzr merge lp:~jtv/launchpad/recife-new-resetcurrenttranslation |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Nelson (community) | code | 2010-08-26 | Approve on 2010-08-26 |
|
Review via email:
|
|||
Commit Message
resetCurrentTra
Description of the Change
= resetCurrentTra
For the Recife feature branch, upon discussion with Danilo. This re-implements POTMsgSet.
However that change breaks a view test. The breakage would have been hard to fix (without getting very dirty and making it very brittle) because the one call to resetCurrentTra
So I renamed the old resetCurrentTra
You will see a few things in this branch that may shock you, dear reviewer:
1. old_resetCurren
2. There are no tests for old_resetCurren
How do I look myself in the mirror? Well, I feel it all makes sense if you'll give me a chance to explain.
First, we want old_resetCurren
Second, we want old_resetCurren
With that I conclude my case. I hope I managed to convey the fact that we want old_resetCurren
To test:
{{{
./bin/test -vvc -m lp.translations
./bin/test -vvc -m lp.translations -t pofile-
}}}
No lint left, apart from a few pre-existing complaints about comments surrounded by blank lines. In all of the cases I didn't fix, I felt the code had a legitimate need for creative license. Plus, I don't want to avoid _too_ many conflicts with other people's ongoing work!
Jeroen
| Jeroen T. Vermeulen (jtv) wrote : | # |
Thanks for the review, and glad you enjoyed the MP. :)
> > === modified file 'lib/lp/
> > --- lib/lp/
> +0000
> > +++ lib/lp/
> +0000
> > @@ -300,16 +299,16 @@
> >
> > if self.request.method == 'POST':
> > if self.user is None:
> > - raise UnexpectedFormData, (
> > - 'Anonymous users or users who are not accepting our '
> > - 'licensing terms cannot do POST submissions.')
> > + raise UnexpectedFormData(
> > + "Anonymous users or users who are not accepting our "
> > + "licensing terms cannot do POST submissions.")
>
> Out of interest, is switching to double-quotes by default a personal
> preference or a new LP coding recommendation?
Personal preference. But I do think it's sensible for free-form text where an apostrophe would be perfectly appropriate. IIRC one of these strings even went so far as to backslash-escape an apostrophe. For God's sake, why!?
Personally I use single quotes (to minimize "ink on the page") for identifiers and such, where an apostrophe would not be appropriate, or for empty strings and things close to it.
> > === modified file 'lib/lp/
> > --- lib/lp/
> > +++ lib/lp/
> > +
> > + # Check for translation conflicts and update the required
> > + # attributes.
> > + self._maybeRais
> > + current.
> > + # Converge the current translation only if it is diverged and
> > + # not current upstream.
> > + if current.is_diverged and not current.
> > + current.potemplate = None
> > + pofile.
> > +
> > + def resetCurrentTra
> > + share_with_
>
> OK, I forgot to mention this on the IFace declaration, but I have no idea what
> the other side is (maybe the interface description could say a bit more to
> cater for non-translation folk?). From your tests, it looks like it is
> upstream/
Pretty much, yes: "project" and "Ubuntu." A TranslationMessage is selected as current on the "project" side if it has the is_current_upstream flag set, and on the Ubuntu side if it has the is_current_ubuntu flag set. See lp.translations
> > + """See `IPOTMsgSet`."""
> > + traits = getUtility(
> > + pofile.
> > + current_message = traits.
> > + self, pofile.potemplate, pofile.language)
> > +
> > + if current_message is None:
> > + # Nothing to do here.
>
> Is this an error? If a reset is called on a translation that doesn't yet have
> a translation? I'm sure you've though...

Heh... I enjoyed reading your MP description :)
And yes, I've been in that position before too... the one case (a transition to new infrastructure) where a bad name is a good one.
I've just got one question below about "the other side". But r=me. And great tests :)
> === modified file 'lib/lp/ translations/ browser/ translationmess age.py' translations/ browser/ translationmess age.py 2010-08-23 08:35:29 +0000 translations/ browser/ translationmess age.py 2010-08-26 10:24:07 +0000
> --- lib/lp/
> +++ lib/lp/
> @@ -300,16 +299,16 @@
>
> if self.request.method == 'POST':
> if self.user is None:
> - raise UnexpectedFormData, (
> - 'Anonymous users or users who are not accepting our '
> - 'licensing terms cannot do POST submissions.')
> + raise UnexpectedFormData(
> + "Anonymous users or users who are not accepting our "
> + "licensing terms cannot do POST submissions.")
Out of interest, is switching to double-quotes by default a personal
preference or a new LP coding recommendation?
> === modified file 'lib/lp/ translations/ model/potmsgset .py' translations/ model/potmsgset .py 2010-08-24 11:39:06 +0000 translations/ model/potmsgset .py 2010-08-26 10:24:07 +0000 nslation( self, pofile, lock_timestamp): lock_timestamp is not None) tTranslation( self, pofile, lock_timestamp): TranslationMess age( eTranslationCon flict(current, lock_timestamp) is_current_ ubuntu = False is_current_ upstream:
> --- lib/lp/
> +++ lib/lp/
> @@ -1295,25 +1295,47 @@
>
> return message
>
> - def resetCurrentTra
> - """See `IPOTMsgSet`."""
> -
> - assert(
> -
> + def old_resetCurren
> + """See `POTMsgSet`.
> +
> + This message is OBSOLETE in the Recife feature branch. It's
> + still here only until we replace its one call with the new
> + method.
> + """
> + assert lock_timestamp is not None, "No lock timestamp given."
> current = self.getCurrent
> pofile.potemplate, pofile.language)
> -
> - if (current is not None):
> - # Check for translation conflicts and update the required
> - # attributes.
> - self._maybeRais
> - current.
> - # Converge the current translation only if it is diverged and not
> - # current upstream.
> - is_diverged = current.potemplate is not None
> - if is_diverged and not current.
> - current.potemplate = None
> - pofile.date_changed = UTC_NOW
> + if current is None:
> + return
Nice... I prefer guard code like this too :)
> + eTranslationCon flict(current, lock_timestamp) is_current_ ubuntu = False is_current_ upstream: markChanged( ) nslation( ...
> + # Check for translation conflicts and update the required
> + # attributes.
> + self._maybeRais
> + current.
> + # Converge the current translation only if it is diverged and
> + # not current upstream.
> + if current.is_diverged and not current.
> + current.potemplate = None
> + pofile.
> +
> + def resetCurrentTra