JoshAshby/Fla.gr — pull request #18 by JoshAshby (2013-06-08 22:45:23+00:00)
Title: Couch collections

Collections, working pagination, and much much more!
What
--------
Adds collections to the couchdb models, giving the ability to quickly and easily work with large groups of models. This also represents a turning point with working pagination, as the system now has a unified interface that provides pagination support automatically. No more `pagination.py`! Along with all of this, it updates all the views and controllers to use this new system and the new pagination.
Collections in couch are a little trickier and this is by no means the end of messing with the data layer, as how collections store and paginate so quickly means that the redis database could quickly get out of hand. However, it does represent a stepping stone, getting ready for a quicker and faster fla.gr when the database starts to get bigger.

How it works
---------------------
Just like redis collections, when a collection is first initialized, it tries to grab all the ID's of the couch documents that it represents, from a redis list. If this list isn't there, it updates itself to make this list. Pagination is so fast because it truncates this list of ID's before any objects are even pulled into the collection, meaning that only the objects you need for that page are provided when `fetch()` is finally called.

I'm working on getting the documentation fleshed out a bit, and getting the rest of collections working and written, so it may take a while before this is ready to be merged in.