diff idavoll/tap.py @ 204:b4bf0a5ce50d

Implement storage facilities for the HTTP gateway. Author: ralphm. Fixes #12. One of the storage facilities is PostgreSQL based, providing persistence.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 16 Jul 2008 06:38:32 +0000
parents 8ab16e319bb8
children 43a4d0d6c076
line wrap: on
line diff
--- a/idavoll/tap.py	Mon Jul 14 09:16:16 2008 +0000
+++ b/idavoll/tap.py	Wed Jul 16 06:38:32 2008 +0000
@@ -45,12 +45,18 @@
     # Create backend service with storage
 
     if config['backend'] == 'pgsql':
+        from twisted.enterprise import adbapi
         from idavoll.pgsql_storage import Storage
-        st = Storage(user=config['dbuser'],
-                     database=config['dbname'],
-                     password=config['dbpass'],
-                     host=config['dbhost'],
-                     port=config['dbport'])
+        dbpool = adbapi.ConnectionPool('pyPgSQL.PgSQL',
+                                       user=config['dbuser'],
+                                       password=config['dbuser'],
+                                       database=config['dbname'],
+                                       host=config['dbpass'],
+                                       port=config['dbport'],
+                                       cp_reconnect=True,
+                                       client_encoding='utf-8',
+                                       )
+        st = Storage(dbpool)
     elif config['backend'] == 'memory':
         from idavoll.memory_storage import Storage
         st = Storage()