liqd/adhocracy — pull request #194 by phihag (2013-01-23 02:55:50+00:00)
Title: Import / Export facilities

This pull requests adds basic facilities that allow importing and exporting the data in an adhocracy installation into a human-readable format, which can be imported by other implementations and data analysis tools. This architecture is expected to supersede the current CSV user import as well as integrate our stats analysis reports.

Rationale for incomplete code coverage:

The following lines are the main entry points that interact with the controller. They are executed on every import / export and are therefore believed to be tested. They are also reasonable simple. However, since they may interact with Pylons request/response, they are not easily testable in a unit test.
```
def export(opts):
timeStr = time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime())
title = config.get('adhocracy.site.name', 'adhocracy') + '-' + timeStr
format = opts.get('format', 'json')
return formats.render(export_data(opts), format, title)

def import_(opts, f):
data = formats.read_data(f, opts.get('filetype'))
import_data(opts, data)
model.meta.Session.commit()
```