Merge lp:~leonardr/lazr.restful/cache-unauthorized into lp:lazr.restful
| Status: | Merged |
|---|---|
| Approved by: | Aaron Bentley on 2010-06-14 |
| Approved revision: | 145 |
| Merged at revision: | 134 |
| Proposed branch: | lp:~leonardr/lazr.restful/cache-unauthorized |
| Merge into: | lp:lazr.restful |
| Diff against target: | 0 lines |
| To merge this branch: | bzr merge lp:~leonardr/lazr.restful/cache-unauthorized |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Aaron Bentley (community) | 2010-06-14 | Approve on 2010-06-14 | |
|
Review via email:
|
|||
Description of the Change
This branch makes a number of improvements to the representation cache that were necessary to get the Launchpad test suite to pass.
1. Previously, lazr.restful never invalidated its own cache; it relied on the application knowing when to invalidate. This caused problems in two places (PATCH requests and POST named operations) where a request can modify some object and then immediatley return a representation of that object.
This does not solve all of Launchpad's cache invalidation problems, but it does solve the ones having to do specifically with lazr.restful code (rather than changes made to the dataset outside of lazr.restful). This is what the new _applyChangesPo
2. If an object is totally invisible (because an attempt to generate its URL yields an Unauthorized exception), it should give a 401 response code whether or not it has a cached representation. In the previous version, GET to an invisible object with a cached representation was resulting in a 200 response code with a JSON representation in which every field was redacted.
3. I added the ability for a cache implementation to refuse to cache some object. Launchpad will use this to avoid putting objects into the cache that it doesn't know how to invalidate.
- 146. By Leonard Richardson on 2010-06-14
-
Response to feedback.

This looks good. You might be interested to know that there's a one-liner for "if key in self.dict: del self.dict[key]". It is "self.dict.pop(key, None)".