Merge lp:~adiroiban/launchpad/bug-509252-take-2 into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Henning Eggers on 2010-02-25 | ||||
| Approved revision: | not available | ||||
| Merged at revision: | not available | ||||
| Proposed branch: | lp:~adiroiban/launchpad/bug-509252-take-2 | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
760 lines (+184/-213) 11 files modified
lib/canonical/launchpad/security.py (+0/-15) lib/lp/registry/browser/distroseries.py (+9/-17) lib/lp/registry/browser/sourcepackage.py (+8/-4) lib/lp/registry/doc/distroseries.txt (+18/-76) lib/lp/registry/interfaces/distroseries.py (+4/-13) lib/lp/registry/model/distroseries.py (+12/-37) lib/lp/translations/browser/browser_helpers.py (+4/-6) lib/lp/translations/browser/distroseries.py (+52/-29) lib/lp/translations/browser/tests/distroseries-views.txt (+69/-11) lib/lp/translations/stories/distroseries/xx-distroseries-translations.txt (+3/-5) lib/lp/translations/templates/distroseries-langchart.pt (+5/-0) |
||||
| To merge this branch: | bzr merge lp:~adiroiban/launchpad/bug-509252-take-2 | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Henning Eggers (community) | code | Approve on 2010-02-24 | |
| Michael Nelson (community) | code | 2010-02-17 | Needs Information on 2010-02-18 |
|
Review via email:
|
|||
Commit Message
Refactor checkTranslatio
| Adi Roiban (adiroiban) wrote : | # |
| Michael Nelson (michael.nelson) wrote : | # |
Hi Adi,
Thanks for all the cleanups that you've done in this branch.
After reading the recent email discussion at:
https:/
and particularly BjornT's message:
https:/
I don't think putting the security check into a browser helper is the way to go.
As outlined in the above email:
"The current solution is to have this code in model code, and have the
security adapter ask the model. No code duplication really."
this ensures that any security can be applied not only in the view, but also via other modes of access (API), even if they are not yet enabled.
As it turns out in your code, it seems most of IDistroSeries.
So I wonder if we can do something like this:
http://
That is, simply add a launchpad.View check for IDistroSeriesLa
if not check_permission(
could be replaced simply by:
if not check_permission(
that way you'd have all the security in the right place, separate from the error generation (ie. translation_
I'm not 100%, but as far as I can see, the above should do what you're after while at the same time keeping all the security code in the one place. But I'll check with Henninge to be sure (hence marking this as needs info).
IRC log of conversation starts at:
http://
| Michael Nelson (michael.nelson) wrote : | # |
OK, I spoke to Adi, and he said that the security for IDistroSeriesLa
Without this, I can't see a way to keep these security checks encapsulated in security.py or on the model. I'm going to have to defer to Danilo or Henninge.
| Henning Eggers (henninge) wrote : | # |
Hi Adi,
thanks for cleaning this up. Your code is almost good, I'd just ask two changes of you.
I agree with Michael's point that check_distroser
The code in check_distroser
Something that was already wrong before this branch but that should be cleaned up is this: DistroSeriesVie
So my first request is that you find a new implementation for DistroSeriesVie
My other request is that you move check_distroser
Finally I noticed DistroSeries.
Thanks. ;-)
| Adi Roiban (adiroiban) wrote : | # |
DistroSeriesVie
<metal:
If we want to remove this behavior, we would need to raise those exception in Distribution URL traversal for series... and then things will get a bit complicated as those exception should be raised only for „translations” facet.
-------
There are a couple of view tests in translations/
-----
Thanks for the getDistroSeries
| Henning Eggers (henninge) wrote : | # |
Hi Adi,
sorry for not replying but I had expected that you push an updated branch with whatever changes you see possible.
I did not know that metal tags are being used to raise exceptions and I am pretty sure that should not be that way. If you think it's too much work to improve that in this branch, I can understand that. Please file a bug so that it gets done at some later time.
So, a new push to the branch would be the next thing to get the review forward.
Cheers,
Henning
| Adi Roiban (adiroiban) wrote : | # |
Hi,
Don't worry about the communication problem ... be happy :)
I have opened a new bug for TAL expression used for raising an exception.
I have merged the tests for translation permissions.
Here is the diff. Thanks!
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -37,10 +37,8 @@
from lp.services.
from lp.registry.
from lp.registry.
-from lp.translations
+from lp.translations
check_
-from lp.translations
- IDistroSeriesLa
from lp.services.
from lp.registry.
Structural
@@ -81,19 +79,12 @@
except IndexError:
# Unknown language code.
raise NotFoundError
- distroserieslang = self.context.
- if distroserieslang is None:
- # There is no IDistroSeriesLa
- # but we still need to list it as an available language, so we
- # generate a dummy one so users have a chance to get to it in the
- # navigation and start adding translations for it.
- distroserieslangset = getUtility(
- distroserieslang = distroserieslan
- self.context, lang)
+ distroserieslang = self.context.
# Check if user is able to view the translations for
- # this distribution series
+ # this distribution series language.
+ # If not, raise TranslationUnav
return distroserieslang
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -40,7 +40,7 @@
from lp.registry.
from lp.registry.
from lp.registry.
-from lp.translations
+from lp.translations
check_
from lp.translations
from canonical.launchpad import _
@@ -68,7 +68,8 @@
# If we are able to view the translations for distribution series
# we should also be allowed to see them for a distribution
- # source package
+ # source package.
+ # If not, raise TranslationUnav
return sourcepackage_pots
=== modified file 'lib/lp/
| Henning Eggers (henninge) wrote : | # |
Thanks, this looks much better. Unfortunately the diff shows conflicts, so I guess you need to merge devel and push again for the diff to be correct.
Also, is there no unit test that could go through all the different SeriesStatus values? Doing this in a doc test looks like it's in the wrong place. But please only do this if it is fairly easy. I think this branch is already old enough ... ;-)
| Adi Roiban (adiroiban) wrote : | # |
În data de Mi, 24-02-2010 la 17:42 +0000, Henning Eggers a scris:
> Thanks, this looks much better. Unfortunately the diff shows
> conflicts, so I guess you need to merge devel and push again for the
> diff to be correct.
Conflict solved.
> Also, is there no unit test that could go through all the different
> SeriesStatus values? Doing this in a doc test looks like it's in the
> wrong place. But please only do this if it is fairly easy. I think
> this branch is already old enough ... ;-)
I was thinking that view unit tests should be put in:
lib/lp/
translations/
I have just moved those tests from registry/
file.
Are you saying that we should not write unit tests using doctest format?
Cheers
--
Adi Roiban
| Henning Eggers (henninge) wrote : | # |
> Conflict solved.
Cool, looks good. ;)
> Are you saying that we should not write unit tests using doctest format?
Yes, at least that's what I do. They execute slower, don't they? But as you pointed out, the test was already there, so you just extended it. That's what I do, too ... ;) So you can keep it as it is if you want to.
Thanks for the extra comments in the code, btw. And all the clean-up work!
You have a double "allowed allowed" in there somewhere, btw.
Cheers,
Henning
| Adi Roiban (adiroiban) wrote : | # |
În data de Mi, 24-02-2010 la 18:27 +0000, Henning Eggers a scris:
> Review: Approve code
> > Conflict solved.
>
> Cool, looks good. ;)
>
>
> > Are you saying that we should not write unit tests using doctest format?
>
> Yes, at least that's what I do. They execute slower, don't they? But
> as you pointed out, the test was already there, so you just extended
> it. That's what I do, too ... ;) So you can keep it as it is if you
> want to.
OK. This is not the only unit test written in doctest format.
$ ls lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
Maybe we should open a bug to convert all those test from doctest to
"pure" python code.
> Thanks for the extra comments in the code, btw. And all the clean-up
> work!
> You have a double "allowed allowed" in there somewhere, btw.
Typo fixed and pushed.
When you have time, can you please send this branch to ec2 test?
Kindest regards,
--
Adi Roiban
| Henning Eggers (henninge) wrote : | # |
I am having trouble landing this. First, there is the current problem with ec2 test not sending emails, so the failure was kind of obscure. Secondly, after merging the current devel, it failed because "python-
Now, this error remains when running "make build":
ZopeXMLConf
ImportError: cannot import name check_distroser
| Adi Roiban (adiroiban) wrote : | # |
Hm...
I did not get the „python-
I have fixed the problem and pushed the branch.

= Bug 509252 = /code.edge. launchpad. net/~adiroiban/ launchpad/ bug-340662- take-2/ +merge/ 17598) the POTemplateSubse tNavigation will render the AdminPOTemplate Subset useless.
After landing the fix for bug 340662 (https:/
We should clean the security.py.
AdminPOTemplate Subset was added to fix bug 497438
== Proposed fix ==
Remove unused classed from security.py and refactor
== Pre-implementation notes ==
Talking with Henning we decide not to include security checking code in the model. This is why the logic of showing translations of a series was spitted between the model and the view and the security checks were done in multiple places.
This restriction lead to a strange implementation where the check was done both in the view and the model and it was a source of confusion.
I merged this logic in a browser helper function and now the security check is only done once.
== Implementation details ==
These changes renders the AdminDistroSeri esLanguage class from security.py useless, so I have also removed it.
== Tests == translations -t distroseries-views
lp-test -t distroseries-
== Demo and Q/A == l10n-coordinato r). /launchpad. dev/~ubuntu- l10n-coordinato r
Make sure you are a member of Ubuntu Translation Coordinators team (ubuntu-
https:/
Go to the translation page for a distribution and hide translations for this series /translations. launchpad. dev/ubuntu/ hoary/+ admin
ie: https:/
Next go to the distribution series +template page /translations. launchpad. dev/ubuntu/ hoary/+ templates
https:/
You should see the Administer page for Evolution templates, including disabled-template .
As a member of Ubuntu Translation Coordinators team you should be able to administer them, just like for a normal series.
Login as a normal user you should see a page informing that the translations are currently closed
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: /launchpad/ security. py registry/ browser/ distroseries. py registry/ browser/ sourcepackage. py registry/ interfaces/ distroseries. py registry/ model/distroser ies.py translations/ browser/ browser_ helpers. py translations/ browser/ distroseries. py translations/ stories/ distroseries/ xx-distroseries -translations. txt
lib/canonical
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/ registry/ browser/ sourcepackage. py interface' (No module named restful)
29: [F0401] Unable to import 'lazr.restful.
lib/lp/ registry/ interfaces/ distroseries. py fields' (No module named restful) declarations' (No module named restful) sionField. _validate] Use super on an old style class blic.getPackage Uploads] Operator not preceded by a space =_("Return items that are more recent than this " False),
23: [F0401] Unable to import 'lazr.enum' (No module named enum)
50: [F0401] Unable to import 'lazr.restful.
51: [F0401] Unable to import 'lazr.restful.
117: [E1002, DistroSeriesVer
447: [C0322, IDistroSeriesPu
description
^
"timestamp."),
required=
status=Choice(
vocabulary= DBEnumeratedTyp e, _("Package Upload Status"),
title=
des...