| 201 | |
| 202 | def _get_pool (self): |
| 203 | if not hasattr (self.__class__, '_pool'): |
| 204 | from django.conf import settings |
| 205 | Database.OPT_Threading = 1 |
| 206 | if len(settings.DATABASE_HOST.strip()) == 0: |
| 207 | settings.DATABASE_HOST = 'localhost' |
| 208 | if len(settings.DATABASE_PORT.strip()) != 0: |
| 209 | dsn = Database.makedsn(settings.DATABASE_HOST, int(settings.DATABASE_PORT), settings.DATABASE_NAME) |
| 210 | p = Database.SessionPool(settings.DATABASE_USER, settings.DATABASE_PASSWORD, dsn, settings.DATABASE_SESSION_POOL_MIN, settings.DATABASE_SESSION_POOL_MAX, settings.DATABASE_SESSION_POOL_INCREMENT, threaded = True) |
| 211 | else: |
| 212 | p = Database.SessionPool(settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME, settings.DATABASE_SESSION_POOL_MIN, settings.DATABASE_SESSION_POOL_MAX, settings.DATABASE_SESSION_POOL_INCREMENT, threaded = True) |
| 213 | setattr(self.__class__, '_pool', p) |
207 | | if not self._valid_connection(): |
208 | | if len(settings.DATABASE_HOST.strip()) == 0: |
209 | | settings.DATABASE_HOST = 'localhost' |
210 | | if len(settings.DATABASE_PORT.strip()) != 0: |
211 | | dsn = Database.makedsn(settings.DATABASE_HOST, int(settings.DATABASE_PORT), settings.DATABASE_NAME) |
212 | | self.connection = Database.connect(settings.DATABASE_USER, settings.DATABASE_PASSWORD, dsn, **self.options) |
213 | | else: |
214 | | conn_string = "%s/%s@%s" % (settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME) |
215 | | self.connection = Database.connect(conn_string, **self.options) |
| 226 | if settings.DATABASE_SESSION_POOL: |
| 227 | if self.pool is not None: |
| 228 | if self.connection is None: |
| 229 | self.connection = self.pool.acquire() |
| 230 | else: |
| 231 | if not self._valid_connection(): |
| 232 | if len(settings.DATABASE_HOST.strip()) == 0: |
| 233 | settings.DATABASE_HOST = 'localhost' |
| 234 | if len(settings.DATABASE_PORT.strip()) != 0: |
| 235 | dsn = Database.makedsn(settings.DATABASE_HOST, int(settings.DATABASE_PORT), settings.DATABASE_NAME) |
| 236 | self.connection = Database.connect(settings.DATABASE_USER, settings.DATABASE_PASSWORD, dsn, **self.options) |
| 237 | else: |
| 238 | conn_string = "%s/%s@%s" % (settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME) |
| 239 | self.connection = Database.connect(conn_string, **self.options) |
| 240 | |
| 241 | |