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
=== modified file 'lib/canonical/launchpad/security.py'
--- lib/canonical/launchpad/security.py 2010-03-25 08:48:14 +0000
+++ lib/canonical/launchpad/security.py 2010-04-12 18:02:27 +0000
@@ -1628,11 +1628,21 @@
1628 return team in user.person.getAdministratedTeams()1628 return team in user.person.getAdministratedTeams()
16291629
16301630
1631class ViewLanguageSet(AnonymousAuthorization):
1632 """Anyone can view an ILangaugeSet."""
1633 usedfor = ILanguageSet
1634
1635
1631class AdminLanguageSet(OnlyRosettaExpertsAndAdmins):1636class AdminLanguageSet(OnlyRosettaExpertsAndAdmins):
1632 permission = 'launchpad.Admin'1637 permission = 'launchpad.Admin'
1633 usedfor = ILanguageSet1638 usedfor = ILanguageSet
16341639
16351640
1641class ViewLanguage(AnonymousAuthorization):
1642 """Anyone can view an ILangauge."""
1643 usedfor = ILanguage
1644
1645
1636class AdminLanguage(OnlyRosettaExpertsAndAdmins):1646class AdminLanguage(OnlyRosettaExpertsAndAdmins):
1637 permission = 'launchpad.Admin'1647 permission = 'launchpad.Admin'
1638 usedfor = ILanguage1648 usedfor = ILanguage
16391649
=== modified file 'lib/lp/services/worlddata/interfaces/language.py'
--- lib/lp/services/worlddata/interfaces/language.py 2010-03-05 14:02:05 +0000
+++ lib/lp/services/worlddata/interfaces/language.py 2010-04-12 18:02:27 +0000
@@ -150,7 +150,12 @@
150150
151151
152class ILanguageSet(Interface):152class ILanguageSet(Interface):
153 """The collection of languages."""153 """The collection of languages.
154
155 The standard get method will return only the visible languages.
156 If you want to access all languages known to Launchpad, use
157 the getAllLanguages method.
158 """
154159
155 export_as_webservice_collection(ILanguage)160 export_as_webservice_collection(ILanguage)
156161
157162
=== modified file 'lib/lp/services/worlddata/stories/webservice/xx-language.txt'
--- lib/lp/services/worlddata/stories/webservice/xx-language.txt 2010-03-05 23:38:12 +0000
+++ lib/lp/services/worlddata/stories/webservice/xx-language.txt 2010-04-12 18:02:27 +0000
@@ -7,7 +7,7 @@
7The language information from Launchpad can be queried using7The language information from Launchpad can be queried using
8'/+languages/CC', where CC is the language code.8'/+languages/CC', where CC is the language code.
99
10 >>> es = webservice.get('/+languages/es').jsonBody()10 >>> es = anon_webservice.get('/+languages/es').jsonBody()
11 >>> es['resource_type_link']11 >>> es['resource_type_link']
12 u'http.../#language'12 u'http.../#language'
13 >>> print es['text_direction']13 >>> print es['text_direction']
@@ -41,7 +41,7 @@
41 ... else:41 ... else:
42 ... list += language['english_name'] + '(hidden)' + "\n"42 ... list += language['english_name'] + '(hidden)' + "\n"
43 ... return list43 ... return list
44 >>> default_languages = webservice.get('/+languages').jsonBody()44 >>> default_languages = anon_webservice.get('/+languages').jsonBody()
45 >>> default_languages['resource_type_link']45 >>> default_languages['resource_type_link']
46 u'http.../#languages'46 u'http.../#languages'
47 >>> languages = get_languages_entries(default_languages)47 >>> languages = get_languages_entries(default_languages)
@@ -56,7 +56,7 @@
56It also contains languages like Afar (Djibouti), which are hidden by56It also contains languages like Afar (Djibouti), which are hidden by
57default.57default.
5858
59 >>> all_languages = webservice.get(59 >>> all_languages = anon_webservice.get(
60 ... '/+languages?'60 ... '/+languages?'
61 ... 'ws.op=getAllLanguages&ws.start=0&ws.size=10'61 ... 'ws.op=getAllLanguages&ws.start=0&ws.size=10'
62 ... ).jsonBody()62 ... ).jsonBody()