Make withsqlite work with multithreaded programs.
The plinth application used by the Freedombox project triggered an
exception in withsqlite when looking up users from the sqlite file,
see <URL: http://lists.alioth.debian.org/pipermail/freedombox-discuss/2013-September/005691.html >
for some details.  This patch make sure the sqlite file is opened in
multithread mode to solve the issue.
Make it a runtime option if sqlite3.connect() should use check_same_thread or not.
Fix merge conflict.
Merge petterreinholdtsen:plinth-multithread:

Make withsqlite work with multithreaded programs.

The plinth application used by the Freedombox project triggered an
exception in withsqlite when looking up users from the sqlite file,
for details, see:

http://lists.alioth.debian.org/pipermail/freedombox-discuss/2013-September/005699.html

This patch make sure the sqlite file is opened in multithread mode to
solve the issue.