(WIP) Content library code for upstream PR - Internal review

For internal review before I open the upstream PR.

Things yet to do:
- [ ] Integrate and update tests
- [ ] Rebase against edx-platform master and squash commits
- [ ] Scope.settings overrides
- [ ] Test with child objects!
- [ ] Test performance (can we have 1,000 problems in the library? 10,000?)

Testing instructions:

1. Check out this branch on a vanilla devstack (not solutions), and do `paver install_python_prereqs` and `paver update_db`
2. As 'edxapp' user, edit `~/cms.env.json` and add `"ENABLE_CONTENT_LIBRARIES": true` to the `FEATURES` object.
3. Edit `~/cms.auth.json`. Go to `MODULESTORE` > `default` > `OPTIONS` > `stores` - it should contain two or three entries. Re-order the entries so that the store with `"NAME": "split",` comes first in the `stores` list. (This makes [split](https://github.com/edx/edx-platform/wiki/Split:-the-versioning,-structure-saving-DAO) the default modulestore for any new courses.)
4. Start `paver devstack studio` and go to `localhost:8001` in your browser.
5. Log in as staff, and create a new library (a new "New library" button should appear at top right of studio home page).
6. Add some content to the library.
7. Go to studio home and go into a course or create a new course.
8. Go to Settings > Advanced Settings and add `"library_content"` to advanced_modules.
9. Go to Content > Outline. Create a new section and subsection, then edit it. Click "Advanced" and add a new "library_content" block.
10. Once the block is added, click "Edit" to edit its settings. Most are explained on the settings editor. For the "Library" setting, you must click "Add", then paste the LibraryLocator of your library. This looks like `library-v1:ProblemX+PR0B`. (It's in the URL when you go to the library in studio). Hit Save.
11. Click "Update now with latest components from the library".
12. Optional: Click "View >" to preview all the blocks found in the library.
13. Hit "Publish", then start up the LMS and go to `localhost:8000`. Browse into the course, and you should see that the block is replaced by random blocks from the library. To test the randomization, click the lowest "STAFF DEBUG INFO" link underneath the module, then click "Delete Student State", then refresh the page.
I don't think that's actually equivalent? I think the equivalent code would need to be:

```python
library = request.json.get('number', request.json.get('library', None))
if library is None:
    raise KeyError
```
... because I'm relying on the `KeyError` to arise from `request.json['library']` (Note that `.get()` never raises `KeyError`)