Merge lp:~leonardr/lazr.restful/fix-request-user into lp:lazr.restful
Proposed by
Leonard Richardson
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~leonardr/lazr.restful/fix-request-user |
Merge into: | lp:lazr.restful |
Diff against target: |
212 lines (+67/-25) 4 files modified
src/lazr/restful/NEWS.txt (+6/-0) src/lazr/restful/declarations.py (+10/-2) src/lazr/restful/docs/webservice-declarations.txt (+50/-22) src/lazr/restful/version.txt (+1/-1) |
To merge this branch: | bzr merge lp:~leonardr/lazr.restful/fix-request-user |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paul Hummer (community) | code | Approve | |
Review via email: mp+19418@code.launchpad.net |
To post a comment you must log in.
This branch changes REQUEST_USER from a marker object to a marker class. The underlying reason is that copy.deepcopy turns a marker object into a different object, but leaves a marker class alone.
Let's say that REQUEST_USER is <object object at 0x123>, and consider a named operation that has REQUEST_USER as a fixed value. The idea is that at runtime, lazr.restful will see that the fixed value is this marker object, determine the current user, and plug that in instead of the marker object.
Now consider what happens in a multiversioned environment, when the named operation's annotations dict for version '1.0' is run through copy.deepcopy() to create the basis for the annotations dict for version '2.0'.
In 2.0, the fixed value is a copy of REQUEST_USER, <object object at 0xabc>. At runtime, lazr.restful checks whether <object object at 0xabc> 'is' <object object at 0x123> and decides that the answer is no. Apparently the web service designer wants this random object <object object at 0xabc> passed in as the value for 'user'. The underlying function takes one look at this random object and barfs--it was expecting an instance of User!
By changing REQUEST_USER to a marker class, we ensure that copy.deepcopy doesn't change it. The '2.0' object is the same as the '1.0' object, and they both return True for 'is REQUEST_USER'.
I tested this by adding a fixed argument to the named operations in webservice- declaration, and making sure values were inherited between versions 2.0 and 3.0.