Merge lp:~adiroiban/launchpad/bug-561355 into lp:launchpad

Proposed by Adi Roiban
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~adiroiban/launchpad/bug-561355
Merge into: lp:launchpad
Diff against target: 74 lines (+19/-4)
3 files modified
lib/canonical/launchpad/security.py (+10/-0)
lib/lp/services/worlddata/interfaces/language.py (+6/-1)
lib/lp/services/worlddata/stories/webservice/xx-language.txt (+3/-3)
To merge this branch: bzr merge lp:~adiroiban/launchpad/bug-561355
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+23249@code.launchpad.net

Commit message

Allow all users, including anonymous users to read ILanguageSet and ILanguage using the webservices.

Description of the change

= Bug 561355 =

The ILanguage and ILanguageSet are not visible to anonymous users.

== Proposed fix ==

Add adapters inheriting AnonymousAuthorization.

== Pre-implementation notes ==

I talked with Danilo and the confirmed that those attributes should be visible by anonymous users.

== Implementation details ==

I have also changed the general description for ILanguageSet to inform users that by default, only visible languages are returned.

== Tests ==
lp-test -t xx-language

== Demo and Q/A ==
Make sure you are not logged in.
Go to: https://launchpad.dev/api/devel/+languages

You should see the languages, together with their content.

in launchapdlib
>>> launchpad = Launchpad.login_anonymously('just testing', 'devel', cachedir)
>>> langs = launchpad.languages
>>> for lang in langs[:10]:
... print lang.english_name
...
Abkhazian
Acehnese
Acoli
Adangme
Adyghe; Adygei
Afar
Afrihili
Afrikaans
Akan
Albanian
>>>

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/services/worlddata/interfaces/language.py

== Pylint notices ==

lib/lp/services/worlddata/interfaces/language.py
    18: [F0401] Unable to import 'lazr.enum' (No module named lazr.enum)
    20: [F0401] Unable to import 'lazr.restful.declarations' (No module named lazr.restful.declarations)

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

This looks reasonable, aside from the grammar of the docstring.

I suggest: "The standard get method will return only the visible languages.
If you want to access all languages known to Launchpad, use
the getAllLanguages method."

review: Needs Fixing
Revision history for this message
Adi Roiban (adiroiban) wrote :

Hi Aaron,

Thanks for the review!

I have changed the docstring.

Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/security.py'
2--- lib/canonical/launchpad/security.py 2010-03-25 08:48:14 +0000
3+++ lib/canonical/launchpad/security.py 2010-04-12 18:02:27 +0000
4@@ -1628,11 +1628,21 @@
5 return team in user.person.getAdministratedTeams()
6
7
8+class ViewLanguageSet(AnonymousAuthorization):
9+ """Anyone can view an ILangaugeSet."""
10+ usedfor = ILanguageSet
11+
12+
13 class AdminLanguageSet(OnlyRosettaExpertsAndAdmins):
14 permission = 'launchpad.Admin'
15 usedfor = ILanguageSet
16
17
18+class ViewLanguage(AnonymousAuthorization):
19+ """Anyone can view an ILangauge."""
20+ usedfor = ILanguage
21+
22+
23 class AdminLanguage(OnlyRosettaExpertsAndAdmins):
24 permission = 'launchpad.Admin'
25 usedfor = ILanguage
26
27=== modified file 'lib/lp/services/worlddata/interfaces/language.py'
28--- lib/lp/services/worlddata/interfaces/language.py 2010-03-05 14:02:05 +0000
29+++ lib/lp/services/worlddata/interfaces/language.py 2010-04-12 18:02:27 +0000
30@@ -150,7 +150,12 @@
31
32
33 class ILanguageSet(Interface):
34- """The collection of languages."""
35+ """The collection of languages.
36+
37+ The standard get method will return only the visible languages.
38+ If you want to access all languages known to Launchpad, use
39+ the getAllLanguages method.
40+ """
41
42 export_as_webservice_collection(ILanguage)
43
44
45=== modified file 'lib/lp/services/worlddata/stories/webservice/xx-language.txt'
46--- lib/lp/services/worlddata/stories/webservice/xx-language.txt 2010-03-05 23:38:12 +0000
47+++ lib/lp/services/worlddata/stories/webservice/xx-language.txt 2010-04-12 18:02:27 +0000
48@@ -7,7 +7,7 @@
49 The language information from Launchpad can be queried using
50 '/+languages/CC', where CC is the language code.
51
52- >>> es = webservice.get('/+languages/es').jsonBody()
53+ >>> es = anon_webservice.get('/+languages/es').jsonBody()
54 >>> es['resource_type_link']
55 u'http.../#language'
56 >>> print es['text_direction']
57@@ -41,7 +41,7 @@
58 ... else:
59 ... list += language['english_name'] + '(hidden)' + "\n"
60 ... return list
61- >>> default_languages = webservice.get('/+languages').jsonBody()
62+ >>> default_languages = anon_webservice.get('/+languages').jsonBody()
63 >>> default_languages['resource_type_link']
64 u'http.../#languages'
65 >>> languages = get_languages_entries(default_languages)
66@@ -56,7 +56,7 @@
67 It also contains languages like Afar (Djibouti), which are hidden by
68 default.
69
70- >>> all_languages = webservice.get(
71+ >>> all_languages = anon_webservice.get(
72 ... '/+languages?'
73 ... 'ws.op=getAllLanguages&ws.start=0&ws.size=10'
74 ... ).jsonBody()