Make checks for celebrity persons and roles easier
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Fix Released
|
Low
|
Henning Eggers |
Bug Description
A lot of celebrities are IPerson objects and they are used to check if a certain person is (or is inTeam of) that celbrity person. This involves a lot of boilerplate for each such check, like this:
admins = getUtility(
result = user.inTeam(admins)
It would be much nicer to be able to do:
result = user.is_admin
or at least
result = IPersonRole(
An adapter that provides this would make a lot of code much more readable. Some of this was attempted with the file lib/lp/
Another sevice that this adapter should provide is to check for certain roles regarding an object, like this:
result = IPersonRole(
although this not really shorter than
result = user.inTeam(
It gets better with a method that checks multiple attributes, like this:
result = IPersonRule(
Obviously, checks like this are mostly done in security.py and so it would be really convenient for AuthenticationB
Related branches
- Abel Deuring (community): Approve (code)
-
Diff: 612 lines (+376/-68)8 files modifiedlib/canonical/launchpad/doc/celebrities.txt (+32/-1)
lib/canonical/launchpad/interfaces/launchpad.py (+98/-0)
lib/canonical/launchpad/security.py (+20/-13)
lib/canonical/launchpad/tests/test_personroles.py (+151/-0)
lib/canonical/launchpad/utilities/personroles.py (+55/-0)
lib/canonical/launchpad/zcml/launchpad.zcml (+10/-0)
lib/lp/services/permission_helpers.py (+0/-46)
lib/lp/translations/model/translationimportqueue.py (+10/-8)
tags: | added: tech-debt |
Changed in launchpad-foundations: | |
status: | New → Triaged |
importance: | Undecided → Low |
Changed in launchpad-foundations: | |
status: | Triaged → Fix Committed |
assignee: | nobody → Henning Eggers (henninge) |
milestone: | none → 10.01 |
tags: | added: qa-ok |
Changed in launchpad-foundations: | |
status: | Fix Committed → Fix Released |