Merge lp://staging/~adeuring/launchpad/api-query-permissions-on-object into lp://staging/launchpad
Status: | Merged |
---|---|
Approved by: | Aaron Bentley |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12889 |
Proposed branch: | lp://staging/~adeuring/launchpad/api-query-permissions-on-object |
Merge into: | lp://staging/launchpad |
Diff against target: |
301 lines (+200/-2) 6 files modified
lib/lp/registry/interfaces/person.py (+27/-0) lib/lp/registry/interfaces/sourcepackage.py (+15/-1) lib/lp/registry/model/person.py (+12/-0) lib/lp/registry/model/sourcepackage.py (+14/-0) lib/lp/registry/tests/test_person.py (+46/-0) lib/lp/registry/tests/test_sourcepackage.py (+86/-1) |
To merge this branch: | bzr merge lp://staging/~adeuring/launchpad/api-query-permissions-on-object |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aaron Bentley (community) | Approve | ||
Abel Deuring (community) | Needs Resubmitting | ||
Robert Collins (community) | Needs Fixing | ||
Review via email: mp+58136@code.staging.launchpad.net |
Commit message
[r=abentley][bug=758920][incr] new methods SourcePackage.
Description of the change
This branch adds two new methods IPerson.canAccess() and IPerson.canWrite(), which tell if a given person can access or change attributes of an object. The original idea was to expose these methods via the webservice API, but that seems to be at least quite difficult, if not impossible: The @operation_
The goal of this work is to allow Javascript code to figure out if the current user can access a property or method or if he can set a a property in order to decide if the current user should be shown some controls to change some settings. This can also be achieved by properties IObject.
The actual issue is bug 758920: The JS code for the translation sharing details page needs to know, if the current user can set the branch of a series, and if he can change some translation retaed settings. This branch adds a property IProductSeries.
I'll add similar properties in another branch.
I discussed the details of the canWrite(), canAccess() methods wioth Gary; Aarn suggested the usage of properties.
tests:
./bin/test registry -vvt test_productser
./bin/test registry -vvt TestPerson.test_can
I have a couple of concerns here.
Firstly, if these are properties they will be calculated on -every- render of the object. Permission checks are not always cheap and are sometimes very expensive. We will be shooting our performance in the foot.
Secondly, will it scale performance wise ;)
I think that rather than calculating every possible permission on every API generation we should instead permit specifying the precise things needed for a page and only calculate those.
I'm very confident that the overhead of this will mount up, so I'm going to needsfixing this and put the branch into in-progress. Sorry :(.
I'm happy to talk/IRC/email about implementation strategies if needed; offhand it looks to me like any given page knows the permissions that will be needed a-priori so can inject them into the json cache at runtime. This is probably simpler and may remove the need to expose the userCanWrite logic etc entirely.