Skip to content

Commit

Permalink
Properly close the connection in permission checks and also flush cre…
Browse files Browse the repository at this point in the history
…ate command to make sure that it's finished
  • Loading branch information
domoritz committed Apr 24, 2013
1 parent 4c926d3 commit 5724497
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ckanext/datastore/plugin.py
Expand Up @@ -182,7 +182,7 @@ def _read_connection_has_correct_privileges(self):
write_connection.execute(drop_foo_sql)

try:
write_connection.execute(u'CREATE TABLE _foo ()')
write_connection.execute(u'CREATE TABLE _foo ()').close()
for privilege in ['INSERT', 'UPDATE', 'DELETE']:
test_privilege_sql = u"SELECT has_table_privilege('_foo', '{privilege}')"
sql = test_privilege_sql.format(privilege=privilege)
Expand All @@ -191,6 +191,8 @@ def _read_connection_has_correct_privileges(self):
return False
finally:
write_connection.execute(drop_foo_sql)
write_connection.close()
read_connection.close()
return True

def _create_alias_table(self):
Expand Down

0 comments on commit 5724497

Please sign in to comment.