Django

Code

Changeset 2581

Show
Ignore:
Timestamp:
03/28/06 11:42:29 (3 years ago)
Author:
adrian
Message:

magic-removal: Merged to [2580]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/django/db/backends/ado_mssql/base.py

    r2457 r2581  
    4444Database.convertVariantToPython = variantToPython 
    4545 
    46 class DatabaseWrapper: 
     46try: 
     47    # Only exists in Python 2.4+ 
     48    from threading import local 
     49except ImportError: 
     50    # Import copy of _thread_local.py from Python 2.4 
     51    from django.utils._threading_local import local 
     52 
     53class DatabaseWrapper(local): 
    4754    def __init__(self): 
    4855        self.connection = None 
  • django/branches/magic-removal/django/db/backends/mysql/base.py

    r2516 r2581  
    4747            return getattr(self.cursor, attr) 
    4848 
    49 class DatabaseWrapper: 
     49try: 
     50    # Only exists in Python 2.4+ 
     51    from threading import local 
     52except ImportError: 
     53    # Import copy of _thread_local.py from Python 2.4 
     54    from django.utils._threading_local import local 
     55 
     56class DatabaseWrapper(local): 
    5057    def __init__(self): 
    5158        self.connection = None 
    5259        self.queries = [] 
    5360 
     61    def _valid_connection(self): 
     62        if self.connection is not None: 
     63            try: 
     64                self.connection.ping() 
     65                return True 
     66            except DatabaseError: 
     67                self.connection.close() 
     68                self.connection = None 
     69        return False 
     70 
    5471    def cursor(self): 
    5572        from django.conf import settings 
    56         if self.connection is None
     73        if not self._valid_connection()
    5774            kwargs = { 
    5875                'user': settings.DATABASE_USER, 
  • django/branches/magic-removal/django/db/backends/postgresql/base.py

    r2457 r2581  
    1010DatabaseError = Database.DatabaseError 
    1111 
    12 class DatabaseWrapper: 
     12try: 
     13    # Only exists in Python 2.4+ 
     14    from threading import local 
     15except ImportError: 
     16    # Import copy of _thread_local.py from Python 2.4 
     17    from django.utils._threading_local import local 
     18 
     19class DatabaseWrapper(local): 
    1320    def __init__(self): 
    1421        self.connection = None 
  • django/branches/magic-removal/django/db/backends/sqlite3/base.py

    r2457 r2581  
    2121    return [utf8(r) for r in row] 
    2222 
    23 class DatabaseWrapper: 
     23try: 
     24    # Only exists in Python 2.4+ 
     25    from threading import local 
     26except ImportError: 
     27    # Import copy of _thread_local.py from Python 2.4 
     28    from django.utils._threading_local import local 
     29 
     30class DatabaseWrapper(local): 
    2431    def __init__(self): 
    2532        self.connection = None