Extend IDomainObjectModification

Currently the notify signal is sent before the database commit has occurred. It
is not possible to listen for modification events and know that the changes
have made it to the database. This can lead to a race condition if you try to
get a record from the database.

For an example see:

https://github.com/ckan/ckanext-archiver/issues/6

This extension of the interface would allow notification after the database
commit has occurred.
[#1879] Set DataStore to legacy mode when using PostgreSQL < 9.x

Up until now the user had to actively set legacy mode when running PG
8.x, and if not you could end up with the full datastore running on an
old postgres version. Features like the SQL search are not properly
supported on these versions, so we need to explicitly disable them when
running on PG 8.x, by setting `legacy_mode` to True.

The current behaviour is that legacy mode will be activated if
`ckan.datastore.read_url` is not present in the configuration and/or
postgres < 9.x.
[#1879] Fix tests

The travis setup explicitly removes the `ckan.datastore.read_url`
setting when running the tests, so we need to use a dummy one.

Also some refactoring
[#1894] Fix convert_to_extras to allow use with normal extras

`convert_to_extras` was adding the custom fields in an unflattened way
during validation to the object that would be later unflattened. This
worked fine if there were only `convert_to_extras` fields, but not if
you were also providing actual extras, eg

    data_dict = {
        'name': 'test-dataset',
        'custom_text': 'Hi',
        'custom_text2': 'Hi2',
        'extras': [
            {'key': 'proper_extra', 'value': 'Bye'},
        ]

    }

This fixes the `convert_to_extras` output and adds new converters test for it.
[#1894] Move test files to proper place

Moved functional tests to ckan/new_tests/logic/test_conversion.py and
added new unit tests for `convert_to_extras` to
ckan/new_tests/logic/test_converters.py
[#1894] Pass a list of keys in the schema to validators

This is included in the context. We pass a copy of the one provided to
validate.
[#1894] Prevent free extras to have the same key as a schema field

Added a new validator to the 'key' field of the extras schema that
checks if the value is present on the 'schema_fields' list that was
added to the context on the previous commit.
[#1894] (Partially) Fix the error_summary for extras validation errors

If there is a validation error on the extras, the error summary would
*always* be `Missing Value`. I guess it was assumed that all validation
errors would be that the extra key was missing. The fix is not ideal, as
it still assumes that all errors will be on the 'key' field (there could
be custom validation on the value), but at least it will show more than
one error, and the ones different from `Missing Value`.

This can furhter be improved, eg changing the macro that renders the
error summary on the templates to allow lists of errors, and maybe
showing the error below the actual extra field (using the index?)
[#1894] Update docs and example_idatasetform to reflect changes

I kept the example of removing the default key/value extras, as this is
what most people would want to do anyway, but mentioning that you have
the option of combining them both on CKAN >= 2.2.1
[#1894] Simplify conversion tests

Don't load `example_idatasetform` as this causes failures in other
tests. Rather pass a schema directly.
[#1612] Treat zero as infinity for facets

For historical reasons, limit=0 needs to be treated as infinity.
[#1909] phix phantomjs peerinvalid phailure
Merge pull request #1909 from wardi/1909-pin-phantomjs-version

Pin phantomjs version
[#1917] Check only for active org memberships

When returning the list of organizations that a user belongs to return
only the organizations that they currently belong to - not orgs that
they were previously a member of.
[#1917] Add tests and docstring for organization_list_for_user()
[#1917] Add another organization_list_for_user() test
Merge branch '1894-use-extras-and-convert_to_extras'
Merge remote-tracking branch 'nigelbabu/backout-facets-breakage'
Add IResourceUpload plugin interface
Generalise IResourceUpload into IResourceModification

Instead of proliferating the interfaces with special resource
cases, by creating yet another resource interface for any resource
creation (not only uploads), IResourceModification incorporates
both uploads and links, but after_create (which replaces
after_upload) provides an additional parameter indicating whether
the resource was uploaded or not.

This entail renaming but also a slightly different workflow in
calling the interface since we must catch deletions before
creations.