Refactor API code to use annotator-store flaskless

Everything seems to work: reading, creating, updating, deleting, searching, permissions seem to work but need better testing, and in general more tests and thorough code review would be good.

To keep a consistent style and make refactoring easier, I decided to use traversal with a `@view_defaults` class everywhere, using the defaults class to specify the `context` predicate, so as to group the views within that. For the same reasons I do not use view names but use a resource for each location (I explictly state `name=''` for clarity, though that could be removed). I think this style works out nicely.

I put some questions in the comments, just search for the question marks.

The dependency on the next (flaskless) annotator-store version has yet to be added.
Exactly
On Jul 11, 2014 5:21 PM, "Gerben" <notifications@github.com> wrote:

> In h/api.py:
>
> > +"""
> > +A quick explanation for those unfamiliar with the Pyramid Web Framework.
> > +The resources defined in resources.py create the tree ('folder') structure using
> > +Pyramid's "traversal" pattern. For example, "/api/annotations/" will result in
> > +h.resources.AnnotationFactory being selected as the request's Context. For each
> > +group of Views, we specify (using @view_defaults) by which type of context these
> > +views can be triggered. That is, which class or interface the context should
> > +have.
> > +For a context (= resource = /some/path/) that implements different actions, we
> > +use @view_config to specify in which situation these views are to be triggered,
> > +for example to use a different view method on a GET than on a POST request.
> > +
> > +For more information about Traversal and View configuration, see (respectively):
> > +http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/traversal.html
> > +http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/viewconfig.html
> > +"""
>
> Yes let's move this to docs as soon as we have some structure there. Would
> perhaps be good to just devote a day or two at some moment to do just
> documentation, but I am always tempted to wait with that until the code is
> completely matured (but when will that happen..).
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/hypothesis/h/pull/1300/files#r14850009>.
>