
class CommunityProxitoSettingsMixin:

    ROOT_URLCONF = 'readthedocs.proxito.urls'
    USE_SUBDOMAIN = True

    @property
    def MIDDLEWARE(self):  # noqa
        # Use our new middleware instead of the old one
        classes = super().MIDDLEWARE
        classes = list(classes)
        index = classes.index(
            'readthedocs.core.middleware.SubdomainMiddleware'
        )
        classes[index] = 'readthedocs.proxito.middleware.ProxitoMiddleware'

        middleware_to_remove = (
            'readthedocs.core.middleware.SingleVersionMiddleware',
            'csp.middleware.CSPMiddleware',
        )
        for mw in middleware_to_remove:
            if mw in classes:
                classes.remove(mw)

        return classes



class CommunityProxitoSettingsMixin:

    ROOT_URLCONF = 'readthedocs.proxito.urls'
    USE_SUBDOMAIN = True

    @property
    def DATABASES(self):
        # This keeps connections to the DB alive,
        # which reduces latency with connecting to postgres
        dbs = getattr(super(), 'DATABASES', {})
        for db in dbs.keys():
            dbs[db]['CONN_MAX_AGE'] = 86400
        return dbs

    @property
    def MIDDLEWARE(self):  # noqa
        # Use our new middleware instead of the old one
        classes = super().MIDDLEWARE
        classes = list(classes)
        index = classes.index(
            'readthedocs.core.middleware.SubdomainMiddleware'
        )
        classes[index] = 'readthedocs.proxito.middleware.ProxitoMiddleware'

        middleware_to_remove = (
            'readthedocs.core.middleware.SingleVersionMiddleware',
            'csp.middleware.CSPMiddleware',
        )
        for mw in middleware_to_remove:
            if mw in classes:
                classes.remove(mw)

        return classes

Expand the logic in our proxito mixin.
Expand the logic in our proxito mixin.

This makes proxito mixin match production for .com/.org
in the areas where we are overriding the same things.

+ 
  
  class CommunityProxitoSettingsMixin:
  
      ROOT_URLCONF = 'readthedocs.proxito.urls'
      USE_SUBDOMAIN = True
+ 
+     @property
+     def DATABASES(self):
+         # This keeps connections to the DB alive,
+         # which reduces latency with connecting to postgres
+         dbs = getattr(super(), 'DATABASES', {})
+         for db in dbs.keys():
+             dbs[db]['CONN_MAX_AGE'] = 86400
+         return dbs
  
      @property
      def MIDDLEWARE(self):  # noqa
          # Use our new middleware instead of the old one
          classes = super().MIDDLEWARE
          classes = list(classes)
          index = classes.index(
              'readthedocs.core.middleware.SubdomainMiddleware'
          )
          classes[index] = 'readthedocs.proxito.middleware.ProxitoMiddleware'
  
          middleware_to_remove = (
              'readthedocs.core.middleware.SingleVersionMiddleware',
              'csp.middleware.CSPMiddleware',
          )
          for mw in middleware_to_remove:
              if mw in classes:
                  classes.remove(mw)
  
          return classes
  
Expand the logic in our proxito mixin.
## Code Before:

class CommunityProxitoSettingsMixin:

    ROOT_URLCONF = 'readthedocs.proxito.urls'
    USE_SUBDOMAIN = True

    @property
    def MIDDLEWARE(self):  # noqa
        # Use our new middleware instead of the old one
        classes = super().MIDDLEWARE
        classes = list(classes)
        index = classes.index(
            'readthedocs.core.middleware.SubdomainMiddleware'
        )
        classes[index] = 'readthedocs.proxito.middleware.ProxitoMiddleware'

        middleware_to_remove = (
            'readthedocs.core.middleware.SingleVersionMiddleware',
            'csp.middleware.CSPMiddleware',
        )
        for mw in middleware_to_remove:
            if mw in classes:
                classes.remove(mw)

        return classes

## Instruction:
Expand the logic in our proxito mixin.
## Code After:


class CommunityProxitoSettingsMixin:

    ROOT_URLCONF = 'readthedocs.proxito.urls'
    USE_SUBDOMAIN = True

    @property
    def DATABASES(self):
        # This keeps connections to the DB alive,
        # which reduces latency with connecting to postgres
        dbs = getattr(super(), 'DATABASES', {})
        for db in dbs.keys():
            dbs[db]['CONN_MAX_AGE'] = 86400
        return dbs

    @property
    def MIDDLEWARE(self):  # noqa
        # Use our new middleware instead of the old one
        classes = super().MIDDLEWARE
        classes = list(classes)
        index = classes.index(
            'readthedocs.core.middleware.SubdomainMiddleware'
        )
        classes[index] = 'readthedocs.proxito.middleware.ProxitoMiddleware'

        middleware_to_remove = (
            'readthedocs.core.middleware.SingleVersionMiddleware',
            'csp.middleware.CSPMiddleware',
        )
        for mw in middleware_to_remove:
            if mw in classes:
                classes.remove(mw)

        return classes
