[CalendarServer-changes] [14428] CalendarServer/branches/users/wsanchez/psycopg2cffi/txdav/base/ datastore/subpostgres.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 18 14:00:58 PST 2015


Revision: 14428
          http://trac.calendarserver.org//changeset/14428
Author:   wsanchez at apple.com
Date:     2015-02-18 14:00:58 -0800 (Wed, 18 Feb 2015)
Log Message:
-----------
Use kwargs to create connection

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/psycopg2cffi/txdav/base/datastore/subpostgres.py

Modified: CalendarServer/branches/users/wsanchez/psycopg2cffi/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/branches/users/wsanchez/psycopg2cffi/txdav/base/datastore/subpostgres.py	2015-02-18 21:12:36 UTC (rev 14427)
+++ CalendarServer/branches/users/wsanchez/psycopg2cffi/txdav/base/datastore/subpostgres.py	2015-02-18 22:00:58 UTC (rev 14428)
@@ -316,24 +316,19 @@
         if databaseName is None:
             databaseName = self.databaseName
 
-        if self.spawnedDBUser:
-            dsn = "{}:dbname={}:{}".format(
-                self.host, databaseName, self.spawnedDBUser
-            )
-        elif self.uid is not None:
-            dsn = "{}:dbname={}:{}".format(
-                self.host, databaseName, pwd.getpwuid(self.uid).pw_name
-            )
-        else:
-            dsn = "{}:dbname={}".format(self.host, databaseName)
+        kwargs = dict(dbname=databaseName, host=self.host)
 
-        kwargs = {}
         if self.port:
-            kwargs["host"] = "{}:{}".format(self.host, self.port)
+            kwargs["port"] = self.port
 
-        return DBAPIConnector(postgres, postgresPreflight, dsn, **kwargs)
+        if self.spawnedDBUser:
+            kwargs["user"] = self.spawnedDBUser
+        elif self.uid is not None:
+            kwargs["user"] = pwd.getpwuid(self.uid).pw_name
 
+        return DBAPIConnector(postgres, postgresPreflight, **kwargs)
 
+
     def produceConnection(self, label="<unlabeled>", databaseName=None):
         """
         Produce a DB-API 2.0 connection pointed at this database.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150218/3370d5c2/attachment-0001.html>


More information about the calendarserver-changes mailing list