Merge lp:~leonardr/lazr.restful/bleed-through-stack into lp:lazr.restful
| Status: | Merged |
|---|---|
| Merged at revision: | not available |
| Proposed branch: | lp:~leonardr/lazr.restful/bleed-through-stack |
| Merge into: | lp:lazr.restful |
| Diff against target: |
348 lines (+321/-0) 2 files modified
src/lazr/restful/docs/utils.txt (+204/-0) src/lazr/restful/utils.py (+117/-0) |
| To merge this branch: | bzr merge lp:~leonardr/lazr.restful/bleed-through-stack |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Jonathan Lange (community) | 2010-01-13 | Approve on 2010-01-14 | |
|
Review via email:
|
|||
| Leonard Richardson (leonardr) wrote : | # |
- 97. By Leonard Richardson on 2010-01-13
-
Removed probably unnecessary substack code.
| Jonathan Lange (jml) wrote : | # |
Hey Leonard,
I can't find much to comment on in this branch -- the test coverage is great, the docs read well and the code is clean.
I don't know of any other general data abstractions like this, but would note that it's got similarities to the layered configuration approach we have in lazr.config. Perhaps there's code that can be shared there.
Some thoughts:
- Although 'append' and 'pop' rhyme nicely with the list methods, I think I would prefer 'push' to 'append', since it makes the stack nature clear. Change at your discretion.
- 'missing' is private, so it should probably be prefixed with an underscore.
- You know your needs best, but I reckon you'll want an __iter__ and maybe keys() & values().
Minor formatting issues:
- in _get_from_
- in the doc, 'my_new_dict = { 1 : 2 }' should read 'my_new_dict = {1: 2}'
cheers,
jml
| Leonard Richardson (leonardr) wrote : | # |
I filed bug 507399 to see if lazr.config can use BleedThroughDict.
- 98. By Leonard Richardson on 2010-01-14
-
Response to feedback.

This branch introduces the BleedThroughDict, a data structure I'll be using in my multi-version web service code to keep track of which Python annotations apply to which versions of the web service.
The basic idea behind the BleedThroughDict: it's a stack of dictionaries that acts like a single dictionary. I can push a dictionary onto the stack containing annotations for version n, then another dictionary containing annotations for version n+1. Any annotations defined in version n but not in version n+1 will 'bleed through', and version n+1 will inherit their values.
I couldn't find a similar data structure already existing, but if there is one in an easily accessible utility library I'm happy to use it instead.
I did not implement all of dict's methods, only the ones I think I'll need for the multi-version code.