| 248 | def _connect_string(self, settings): |
| 249 | if len(settings.DATABASE_HOST.strip()) == 0: |
| 250 | settings.DATABASE_HOST = 'localhost' |
| 251 | if len(settings.DATABASE_PORT.strip()) != 0: |
| 252 | dsn = '%s:%s/%s' % (settings.DATABASE_HOST, |
| 253 | settings.DATABASE_PORT, |
| 254 | settings.DATABASE_NAME) |
| 255 | else: |
| 256 | dsn = settings.DATABASE_NAME |
| 257 | return "%s/%s@%s" % (settings.DATABASE_USER, |
| 258 | settings.DATABASE_PASSWORD, dsn) |
| 259 | |
251 | | if len(settings.DATABASE_HOST.strip()) == 0: |
252 | | settings.DATABASE_HOST = 'localhost' |
253 | | if len(settings.DATABASE_PORT.strip()) != 0: |
254 | | dsn = Database.makedsn(settings.DATABASE_HOST, |
255 | | int(settings.DATABASE_PORT), |
256 | | settings.DATABASE_NAME) |
257 | | self.connection = Database.connect(settings.DATABASE_USER, |
258 | | settings.DATABASE_PASSWORD, |
259 | | dsn, **self.options) |
260 | | else: |
261 | | conn_string = "%s/%s@%s" % (settings.DATABASE_USER, |
262 | | settings.DATABASE_PASSWORD, |
263 | | settings.DATABASE_NAME) |
264 | | self.connection = Database.connect(conn_string, **self.options) |
| 263 | conn_string = self._connect_string(settings) |
| 264 | self.connection = Database.connect(conn_string, **self.options) |