[ckan-changes] [ckan/ckan] 1a1400: [#1725] Add tests for when searching/deleting elem...

GitHub noreply at github.com
Tue Jul 1 10:43:44 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/ckan/ckan
  Commit: 1a1400607fc871c221a29ebb19e1fa84bf08ed2d
      https://github.com/ckan/ckan/commit/1a1400607fc871c221a29ebb19e1fa84bf08ed2d
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-22 (Thu, 22 May 2014)

  Changed paths:
    M ckanext/datastore/tests/test_delete.py
    M ckanext/datastore/tests/test_search.py

  Log Message:
  -----------
  [#1725] Add tests for when searching/deleting elements passing invalid filters


  Commit: f3aa38783c6b70ff77e00737c1dd5a2aef31c628
      https://github.com/ckan/ckan/commit/f3aa38783c6b70ff77e00737c1dd5a2aef31c628
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-22 (Thu, 22 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    A ckanext/datastore/interfaces.py
    A ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] Adds IDataStore interface and extension point to change WHERE clauses

I prefered to extend on `where` instead of `search_data` and `delete_data`
separately to keep the extension code DRY.

The IDataStore extensions' `where` methods are called with the `filters` dict
received from the user. They must check if there's any filter they want to
process and create a `clause` list with elements as tuples following the
pattern:

    (SQL_CLAUSE, PARAM1, PARAM2, ...)

The SQL_CLAUSE can be anything valid on the WHERE clause, for example
`AVG(score) > %s AND AVG(score) < %s`. You have to substitute any user-defined
parameters for `%s`, doesn't matter what their type is (int, string, ...).
Then, for each `%s` inside SQL_CLAUSE, you need to add one PARAM. For example:

    ('AVG(score) > %s AND AVG(score) < %s', 10, 20)

This pattern is needed to be able to sanitize user input and avoid SQL
Injections.

After that, you'll need to delete every key from the `filters` dict that you've
processed. Following our example, you'll have to:

    del filters['score_between']

We need this because we validate the filters' column names against the
DataStore resource's column names. Any filter on a column that doesn't exist on
the resource is invalid and raises an error. If you didn't remove
`filters['score_between']`, you'll receive a "Field 'score_between' doesn't
exist" error.

This is done to give the user a friendlier error message, and avoid another
possible SQL Injection vector.


  Commit: 08e8ee114b724c5a87ada63e46417662ad78f77c
      https://github.com/ckan/ckan/commit/08e8ee114b724c5a87ada63e46417662ad78f77c
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-22 (Thu, 22 May 2014)

  Changed paths:
    M ckanext/datastore/db.py

  Log Message:
  -----------
  [#1725] Forgot to import ckan.plugins


  Commit: f70476cace26184b41fe5410abdd19180d04ca92
      https://github.com/ckan/ckan/commit/f70476cace26184b41fe5410abdd19180d04ca92
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-22 (Thu, 22 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] Custom filters should be added inside parenthesis

The extensions can get a single filter (e.g. "age_not_between") and create two
WHERE clauses (e.g. "age < %s OR age > %s"). To avoid hard-to-track bugs
related to the operator precedence in Postgres, we add every custom filter
inside parenthesis.


  Commit: fa8b0c57cf3e8ef09ed536532ccc0d6a19ffc848
      https://github.com/ckan/ckan/commit/fa8b0c57cf3e8ef09ed536532ccc0d6a19ffc848
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-23 (Fri, 23 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] Filters received shouldn't be modified

This means that if the user sends us:

    'filters': { 'age_between': [20, 30] }

We should return that unmodified in the query result, even though internally
that might be translated to something else or removed.


  Commit: b09085d3fe23decccd695f5f3d13ef889ad7956a
      https://github.com/ckan/ckan/commit/b09085d3fe23decccd695f5f3d13ef889ad7956a
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-23 (Fri, 23 May 2014)

  Changed paths:
    M ckanext/datastore/tests/test_delete.py
    M ckanext/datastore/tests/test_search.py

  Log Message:
  -----------
  [#1725] Guarantee that tests fail for the correct reason


  Commit: 3fed29cbaa3f4045cca899ecd006459f8dc6d295
      https://github.com/ckan/ckan/commit/3fed29cbaa3f4045cca899ecd006459f8dc6d295
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-23 (Fri, 23 May 2014)

  Changed paths:
    M ckanext/datastore/tests/test_search.py

  Log Message:
  -----------
  [#1725] Add test to guarantee that every field in datastore_search is valid


  Commit: 99cc09240ada28d4c2e73b15f2a242a40534f928
      https://github.com/ckan/ckan/commit/99cc09240ada28d4c2e73b15f2a242a40534f928
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-24 (Sat, 24 May 2014)

  Changed paths:
    M ckanext/datastore/db.py

  Log Message:
  -----------
  [#1725] Fix exception caught when there's no CKAN_CURRENT_URL

When we try to get a key from a dict and it doesn't exist, a KeyError is
raised, not a TypeError.


  Commit: f59c914cfd9b4898fa9938471c772945fcbb984f
      https://github.com/ckan/ckan/commit/f59c914cfd9b4898fa9938471c772945fcbb984f
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-27 (Tue, 27 May 2014)

  Changed paths:
    M ckanext/datastore/db.py

  Log Message:
  -----------
  [#1725] Refactor search_data()'s sort to accept an array

We'll need this to allow extensions to add new clauses to it.


  Commit: aa82afc577e90f6744eb869fb2f76fb75c4bbeeb
      https://github.com/ckan/ckan/commit/aa82afc577e90f6744eb869fb2f76fb75c4bbeeb
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-27 (Tue, 27 May 2014)

  Changed paths:
    M ckanext/datastore/db.py

  Log Message:
  -----------
  [#1725] Catch exception thrown when there's no toolkit.request

I have changed this on 3fed29c, but got the following traceback:

```
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/tests/test_interface.py", line 74, in test_filters_sent_arent_modified
    filters=filters.copy())
  File "/usr/lib/ckan/default/src/ckan/ckan/new_tests/helpers.py", line 91, in call_action
    return logic.get_action(action_name)(context=context, data_dict=kwargs)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 414, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/logic/__init__.py", line 530, in wrapper
    return action(context, data_dict)
  File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/logic/action.py", line 339, in datastore_search
    result = db.search(context, data_dict)
  File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/db.py", line 1141, in search
    return search_data(context, data_dict)
  File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/db.py", line 947, in search_data
    _insert_links(data_dict, limit, offset)
  File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/db.py", line 848, in _insert_links
    urlstring = toolkit.request.environ['CKAN_CURRENT_URL']
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/maintain.py", line 75, in custom__getattr__
    depricated = __old_getattr__(self, '__depricated_properties__')
  File "/usr/local/lib/python2.7/dist-packages/paste/registry.py", line 137, in __getattr__
    return getattr(self._current_obj(), attr)
  File "/usr/local/lib/python2.7/dist-packages/paste/registry.py", line 197, in _current_obj
    'thread' % self.____name__)
TypeError: No object (name: request) has been registered for this thread
```


  Commit: 8e4c5c78072b9728f7c742664f807995a0a834ab
      https://github.com/ckan/ckan/commit/8e4c5c78072b9728f7c742664f807995a0a834ab
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-27 (Tue, 27 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] Move validations to IDataStore's validate_query() method

This commit is the first step towards moving all validations of the received
`data_dict` to a single place. This was the easiest way I could think of to
allow extensions to modify our validation rules.

Every IDataStore extension should implement a `validate_query()` method that
receives the context, the data_dict, and the list of fields the current
resource has. The data_dict is a copy, so the extension is able to mess with it
without problems.

Inside that method, the extension will check everything it understands (e.g.
filters, fields, sorts). When finding something, it should remove it from the
data_dict. In the end, return the data_dict with everything it understands
removed. This new data_dict will be passed to the next extension.

After we do this with every extension available, we expect to have a data_dict
with empty values. For example:

```
    # Before calling
    data_dict = {
  'fields': ['age', 'distance'],
  'filters': {
      'age': 25,
      'distance': 5
  }
    }

    # After calling
    data_dict = {
  'fields': [],
  'filters': {}
    }
```

In that case, the validation succeeds and we can keep going. If there's still
any element left in the data_dict, that means that no extension understands it,
and we'll throw a ValidationError.


  Commit: 6d24cca287e3f789be65b3282606f7c3d7ef8baf
      https://github.com/ckan/ckan/commit/6d24cca287e3f789be65b3282606f7c3d7ef8baf
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-27 (Tue, 27 May 2014)

  Changed paths:
    A ckanext/datastore/tests/sample_datastore_plugin.py
    M ckanext/datastore/tests/test_interface.py
    M setup.py

  Log Message:
  -----------
  [#1725] Create proper plugin for testing

Instead of loading the plugin in a hackish way, we create a proper plugin and
load it the same way any other plugins is loaded.


  Commit: 675126f9d4eef025b155f1600d6f6aa34ea25b68
      https://github.com/ckan/ckan/commit/675126f9d4eef025b155f1600d6f6aa34ea25b68
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-27 (Tue, 27 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    A ckanext/datastore/helpers.py
    M ckanext/datastore/logic/action.py
    A ckanext/datastore/tests/test_helpers.py
    M ckanext/datastore/tests/test_unit.py

  Log Message:
  -----------
  [#1725] Move db._get_list to datastore_helpers.get_list

This method was already being used by action.py, and we'll need it soon enough
in other parts of the code, so we'd better make it public.


  Commit: f84e4c7239d00f263ec1fa89a9686c186511bf2c
      https://github.com/ckan/ckan/commit/f84e4c7239d00f263ec1fa89a9686c186511bf2c
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/sample_datastore_plugin.py

  Log Message:
  -----------
  [#1725] Refactor DataStore's WHERE code to the DataStore plugin

The intent is for us to use the same extension points as third-party plugins,
so we can test that they work and that they're extensible enough.


  Commit: d2124503dfef1697965eca439decdd9902f43529
      https://github.com/ckan/ckan/commit/d2124503dfef1697965eca439decdd9902f43529
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py

  Log Message:
  -----------
  [#1725] Adds search_data() extension point and change DataStore to use it

In a high level, extensions that implement this method are expected to add what
they want into a query_dict dictionary, defined as:

```
{
    'select': [],    # list
    'ts_query': '',  # string
    'sort': [],      # list
    'limit': 100,    # int
    'offset': 0      # int
}
```

This dictionary will be passed to each extension, and they can add or remove
attributes to it. Because of this, the order the extensions are loaded in the
.ini file matter.

At this point, the validations defined in validate_query() have already run.


  Commit: 513e94d6f3ceb49df5da8f388b2d8400e9f6b052
      https://github.com/ckan/ckan/commit/513e94d6f3ceb49df5da8f388b2d8400e9f6b052
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/tests/test_helpers.py

  Log Message:
  -----------
  [#1725] Fix PEP8 errors


  Commit: 860a557a50491d51c6935ba1187394df82f2fd7e
      https://github.com/ckan/ckan/commit/860a557a50491d51c6935ba1187394df82f2fd7e
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/db.py

  Log Message:
  -----------
  [#1725] Remove useless code

This was moved to the Datastore plugin, so there's no need to be here anymore.


  Commit: 256e80d6871ed6c6df04f4a0829d5f3e65d4ce37
      https://github.com/ckan/ckan/commit/256e80d6871ed6c6df04f4a0829d5f3e65d4ce37
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/tests/test_delete.py
    M ckanext/datastore/tests/test_search.py

  Log Message:
  -----------
  [#1725] Add test to guarantee that the filters received are in a dict


  Commit: 1e29f22af5ad1bf22bdad8b1b5209083aa1355db
      https://github.com/ckan/ckan/commit/1e29f22af5ad1bf22bdad8b1b5209083aa1355db
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] Add tests asserting that the IDataStore.where() works for delete

It should be used both on datastore_create and datastore_delete.


  Commit: 059a24b97427706b505af50ee681f469a4c5fce2
      https://github.com/ckan/ckan/commit/059a24b97427706b505af50ee681f469a4c5fce2
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/sample_datastore_plugin.py
    M ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] Add delete_data() extension point and remove where()

@amercader and I agreed that, even though in most cases both select_data() and
delete_data() would create the WHERE clauses with the same code, it's easier to
understand the WHERE being created inside each one of those, not on a separate
where() extension point.


  Commit: d884b6d896f8076d7223414640775807e6d95eaf
      https://github.com/ckan/ckan/commit/d884b6d896f8076d7223414640775807e6d95eaf
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/sample_datastore_plugin.py

  Log Message:
  -----------
  [#1725] Rename IDataStore -> IDatastore

This makes it consistent with the plugin name (DatastorePlugin).


  Commit: 6ba586860d4a5bb86980e7e789789ed2c3dfa4f1
      https://github.com/ckan/ckan/commit/6ba586860d4a5bb86980e7e789789ed2c3dfa4f1
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/sample_datastore_plugin.py

  Log Message:
  -----------
  [#1725] Reorder arguments on search_data() and delete_data()

This keeps our current 3 extensions points, search_data(), delete_data(), and
validate_query(), with the same initial 3 arguments, in the same order. The
interface becomes a bit more consistent.


  Commit: 5854436b159adf7363b4acfead8300ae46052ea1
      https://github.com/ckan/ckan/commit/5854436b159adf7363b4acfead8300ae46052ea1
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckan/new_tests/logic/action/test_update.py
    M ckan/new_tests/logic/test_validators.py
    M ckan/templates/package/snippets/package_form.html
    M ckan/tests/functional/test_tracking.py
    M ckan/tests/test_coding_standards.py

  Log Message:
  -----------
  Merge branch 'master' into 1725-extend-datastore


  Commit: fafeef9ca07136b8231750f3defd65e890ed7a54
      https://github.com/ckan/ckan/commit/fafeef9ca07136b8231750f3defd65e890ed7a54
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-28 (Wed, 28 May 2014)

  Changed paths:
    M ckan/tests/test_coding_standards.py

  Log Message:
  -----------
  Merge branch 'master' into 1725-extend-datastore


  Commit: cfa4e6f9361e5276031bebe486a578e35dcbd947
      https://github.com/ckan/ckan/commit/cfa4e6f9361e5276031bebe486a578e35dcbd947
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-05-29 (Thu, 29 May 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/sample_datastore_plugin.py
    M ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] Rename IDatastore's methods to datastore_*

This makes it less likely for some other interface to use the same method
names, and makes it clearer IMO what these methods are about.


  Commit: ebe7f38c2e845eb10466691e977a1332dd7b22bf
      https://github.com/ckan/ckan/commit/ebe7f38c2e845eb10466691e977a1332dd7b22bf
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-09 (Mon, 09 Jun 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/logic/action.py
    M ckanext/datastore/tests/test_search.py
    M ckanext/datastore/tests/test_unit.py
    M requirements.in
    M requirements.txt

  Log Message:
  -----------
  [#1725] datastore_search_sql validates being called with single statement

We're using sqlparse to actually parse the SQL string and make sure it's a
single statement. That means we can be more sure that the user is providing us
with a single statement, and we support SQL statements with semicolons, like
'SELECT * FROM "foo;bar"'.

This is a first step towards avoiding multiple statements even on
datastore_search and datastore_delete, to make our code a bit safer against SQL
Injection vectors.


  Commit: 1b0b4054816286143af27381dd3996e167544484
      https://github.com/ckan/ckan/commit/1b0b4054816286143af27381dd3996e167544484
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-09 (Mon, 09 Jun 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/helpers.py
    M ckanext/datastore/logic/action.py
    M ckanext/datastore/tests/test_helpers.py
    M ckanext/datastore/tests/test_unit.py

  Log Message:
  -----------
  [#1725] Move is_single_statement() to datastore_helpers

It was already being used by datastore_search_sql, so it isn't private. That
being the case, we'd better make it look like it's not private.


  Commit: b4befddbf423b6bd6e4b2b02919e78da6421ce0a
      https://github.com/ckan/ckan/commit/b4befddbf423b6bd6e4b2b02919e78da6421ce0a
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-09 (Mon, 09 Jun 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/tests/sample_datastore_plugin.py
    M ckanext/datastore/tests/test_interface.py

  Log Message:
  -----------
  [#1725] datastore_search and _delete don't work with multiple statements

What we're trying to avoid is for an insecure extension to allow a malicious
user to create queries like:

```
SELECT * FROM "foo" WHERE (1=1); DELETE FROM "foo"; -- AND "bar"='5');
```

This doesn't avoid all possible SQL injection vectors, but it's one less issue
to worry about.


  Commit: df8c1af5fbdc436ed63c76a6f3470c8eae1c2b37
      https://github.com/ckan/ckan/commit/df8c1af5fbdc436ed63c76a6f3470c8eae1c2b37
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M ckanext/datastore/plugin.py
    A ckanext/datastore/tests/test_plugin.py

  Log Message:
  -----------
  [#1725] Datastore must be the first IDatastore plugin loaded

This allows extensions to rely on it running before them.


  Commit: 00943d1477bfa453deee89f9eeb9caa518bdd4d8
      https://github.com/ckan/ckan/commit/00943d1477bfa453deee89f9eeb9caa518bdd4d8
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M ckanext/datastore/interfaces.py

  Log Message:
  -----------
  [#1725] Add docstrings to the IDatastore methods


  Commit: 3c38dce0702c64f27eb3997339a082d02616f7b4
      https://github.com/ckan/ckan/commit/3c38dce0702c64f27eb3997339a082d02616f7b4
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/sample_datastore_plugin.py

  Log Message:
  -----------
  [#1725] Rename datastore_validate_query() to datastore_validate()

The previous name sounded like we were validating the `query_dict`, but we're
actually validating the `data_dict`. I felt `datastore_validate_data_dict()`
would be too big, so `datastore_validate()` seems better.


  Commit: 89bd566e5303f94b9df23b570436f143d0206dec
      https://github.com/ckan/ckan/commit/89bd566e5303f94b9df23b570436f143d0206dec
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-11 (Wed, 11 Jun 2014)

  Changed paths:
    M ckanext/datastore/tests/test_plugin.py

  Log Message:
  -----------
  [#1725] Make sure plugins are unloaded after running test_plugin


  Commit: 38aae975d87620eea8a71019813ebc2e7c9fb99b
      https://github.com/ckan/ckan/commit/38aae975d87620eea8a71019813ebc2e7c9fb99b
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-11 (Wed, 11 Jun 2014)

  Changed paths:
    M ckanext/datastore/plugin.py

  Log Message:
  -----------
  [#1725] Fix bug where we're trying to close using a null connection

The problem is that the code was:

```python
try:
    connection = self.read_engine.connect()
    # ...
finally:
    connection.close()
```

But if `self.read_engine.connect()` raised an exception, `connection` would
never be defined, but we would still try to call `connection.close()`, which
would in turn raise:

```
UnboundLocalError: local variable 'connection' referenced before assignment
```

This would also hide the exception raised when calling `.connect()`, so we
wouldn't know what was the original problem.

This commit fixes it by making sure the `connection` variable exists.


  Commit: 179cbac23ba4450938ca5fd930cc4c1ff34c542c
      https://github.com/ckan/ckan/commit/179cbac23ba4450938ca5fd930cc4c1ff34c542c
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-11 (Wed, 11 Jun 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/helpers.py
    M ckanext/datastore/logic/action.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/test_search.py

  Log Message:
  -----------
  [#1725] Move sort validation to datastore_validate()


  Commit: bc15f14ca4137c72ec34c7d84472078c19ce278d
      https://github.com/ckan/ckan/commit/bc15f14ca4137c72ec34c7d84472078c19ce278d
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-11 (Wed, 11 Jun 2014)

  Changed paths:
    M ckanext/datastore/plugin.py
    R ckanext/datastore/tests/test_plugin.py

  Log Message:
  -----------
  Revert "[#1725] Datastore must be the first IDatastore plugin loaded"

This reverts commit df8c1af5fbdc436ed63c76a6f3470c8eae1c2b37.

Trying to figure out why the tests are failing.

Conflicts:
	ckanext/datastore/tests/test_plugin.py


  Commit: d1284453a82f924828e468b4e28600d7e049881a
      https://github.com/ckan/ckan/commit/d1284453a82f924828e468b4e28600d7e049881a
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-11 (Wed, 11 Jun 2014)

  Changed paths:
    M ckanext/datastore/tests/test_search.py

  Log Message:
  -----------
  [#1725] assert_in is unavailable on Python 2.6


  Commit: 642837604d0e9607b6ccea97b2f6bee513bb776a
      https://github.com/ckan/ckan/commit/642837604d0e9607b6ccea97b2f6bee513bb776a
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-06-13 (Fri, 13 Jun 2014)

  Changed paths:
    M ckanext/datastore/plugin.py
    A ckanext/datastore/tests/test_plugin.py

  Log Message:
  -----------
  [#1725] datastore should be the first IDatastore plugin loaded


  Commit: bf07d13c78ce35510e8838dde232464f319b20ca
      https://github.com/ckan/ckan/commit/bf07d13c78ce35510e8838dde232464f319b20ca
  Author: joetsoi <joe.yeung.tsoi at gmail.com>
  Date:   2014-07-01 (Tue, 01 Jul 2014)

  Changed paths:
    M ckanext/datastore/db.py
    A ckanext/datastore/helpers.py
    A ckanext/datastore/interfaces.py
    M ckanext/datastore/logic/action.py
    M ckanext/datastore/plugin.py
    A ckanext/datastore/tests/sample_datastore_plugin.py
    M ckanext/datastore/tests/test_delete.py
    A ckanext/datastore/tests/test_helpers.py
    A ckanext/datastore/tests/test_interface.py
    A ckanext/datastore/tests/test_plugin.py
    M ckanext/datastore/tests/test_search.py
    M ckanext/datastore/tests/test_unit.py
    M requirements.in
    M requirements.txt
    M setup.py

  Log Message:
  -----------
  Merge branch '1725-extend-datastore'


Compare: https://github.com/ckan/ckan/compare/db774633a726...bf07d13c78ce


More information about the ckan-changes mailing list