Factor out the json structure templates into a tested module.
JSON rendering should be the responsibility of the pyramid views.
Merge links once per collection rather than every time an item is rendered.
Unused constant
Add an execute_counter for keeping track of connection.execute calls during tests and help us avoid performance regressions.
Simplify the groupfinder a little. In general we should try to use session.query(...).get() rather than .filter().