Skip to content

Commit

Permalink
Fix interface error when downloading taxa list (#4131)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimasciput authored Aug 5, 2024
1 parent 14595e7 commit 4d24e97
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
Empty file.
15 changes: 15 additions & 0 deletions bims/database_backend/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import django.db
from psycopg2 import InterfaceError
from django_tenants.postgresql_backend.base import (
DatabaseWrapper as TenantDatabaseWrapper
)


class DatabaseWrapper(TenantDatabaseWrapper):
def create_cursor(self, name=None):
try:
return super().create_cursor(name=name)
except InterfaceError:
django.db.close_old_connections()
django.db.connection.connect()
return super().create_cursor(name=name)
4 changes: 0 additions & 4 deletions core/settings/contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@
absolute_path('pesticide', 'static'),
]

MIDDLEWARE += (
'bims.middleware.VisitorTrackingMiddleware',
)

# for middleware in MIDDLEWARE_CLASSES:
# if middleware not in MIDDLEWARE:
# MIDDLEWARE += (middleware,)
Expand Down
2 changes: 1 addition & 1 deletion core/settings/dev_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

DATABASES = {
'default': {
'ENGINE': 'django_tenants.postgresql_backend',
'ENGINE': 'bims.database_backend',
'NAME': 'gis',
'USER': 'docker',
'PASSWORD': 'docker',
Expand Down
2 changes: 1 addition & 1 deletion core/settings/prod_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

DATABASES = {
'default': {
'ENGINE': 'django_tenants.postgresql_backend',
'ENGINE': 'bims.database_backend',
'NAME': os.environ.get('DATABASE_NAME'),
'USER': os.environ.get('DATABASE_USERNAME'),
'PASSWORD': os.environ.get('DATABASE_PASSWORD'),
Expand Down

0 comments on commit 4d24e97

Please sign in to comment.