# Path: boardinghouse/exceptions.py
# class TemplateSchemaActivation(Forbidden):
#     """
#     An exception that will be raised when a user attempts to activate
#     the settings.TEMPLATE_SCHEMA schema.
#     """
#     def __init__(self, *args, **kwargs):
#         super(TemplateSchemaActivation, self).__init__(
#             'Activating template schema forbidden.', *args, **kwargs
#         )
# 
# class SchemaNotFound(Exception):
#     """
#     An exception that is raised when an attempt to activate a schema that
#     is not in the database is made.
#     """
# 
# Path: boardinghouse/signals.py



import inspect
import logging
import threading
from django.apps import apps
from django.conf import settings
from django.core.cache import cache
from django.core.exceptions import ImproperlyConfigured
from django.db import connection
from django.db.migrations.operations.base import Operation
from django.utils.translation import lazy
from .exceptions import TemplateSchemaActivation, SchemaNotFound
from .signals import find_schema
    from .signals import schema_pre_activate, schema_post_activate
    from .signals import schema_pre_activate, schema_post_activate
    from .signals import schema_pre_activate, schema_post_activate
    Must be passed a string: the internal name of the schema to activate.
    """

    if schema_name == settings.TEMPLATE_SCHEMA:
        raise TemplateSchemaActivation()

    schema_pre_activate.send(sender=None, schema_name=schema_name)
    _set_search_path(schema_name)
    found_schema = _get_search_path()
    if found_schema != schema_name:
        raise SchemaNotFound('Schema activation failed. Expected "{0}", saw "{1}"'.format(
            schema_name, found_schema,
        ))
    schema_post_activate.send(sender=None, schema_name=schema_name)
    _thread_locals.schema = schema_name


def activate_template_schema():
    """
    Activate the template schema.

    You probably don't want to do this. Sometimes you do (like for instance
    to apply migrations).
    """

    _thread_locals.schema = None
    schema_name = settings.TEMPLATE_SCHEMA
    schema_pre_activate.send(sender=None, schema_name=schema_name)
    _set_search_path(schema_name)
    if _get_search_path() != schema_name:

# Path: boardinghouse/exceptions.py
# class TemplateSchemaActivation(Forbidden):
#     """
#     An exception that will be raised when a user attempts to activate
#     the settings.TEMPLATE_SCHEMA schema.
#     """
#     def __init__(self, *args, **kwargs):
#         super(TemplateSchemaActivation, self).__init__(
#             'Activating template schema forbidden.', *args, **kwargs
#         )
# 
# class SchemaNotFound(Exception):
#     """
#     An exception that is raised when an attempt to activate a schema that
#     is not in the database is made.
#     """
# 
# Path: boardinghouse/signals.py



# Path: boardinghouse/schema.py
import inspect
import logging
import threading
from django.apps import apps
from django.conf import settings
from django.core.cache import cache
from django.core.exceptions import ImproperlyConfigured
from django.db import connection
from django.db.migrations.operations.base import Operation
from django.utils.translation import lazy
from .exceptions import TemplateSchemaActivation, SchemaNotFound
from .signals import find_schema
    from .signals import schema_pre_activate, schema_post_activate
    from .signals import schema_pre_activate, schema_post_activate
    from .signals import schema_pre_activate, schema_post_activate

    Must be passed a string: the internal name of the schema to activate.
    """

    if schema_name == settings.TEMPLATE_SCHEMA:
        raise TemplateSchemaActivation()

    schema_pre_activate.send(sender=None, schema_name=schema_name)
    _set_search_path(schema_name)
    found_schema = _get_search_path()
    if found_schema != schema_name:
        raise SchemaNotFound('Schema activation failed. Expected "{0}", saw "{1}"'.format(
            schema_name, found_schema,
        ))
    schema_post_activate.send(sender=None, schema_name=schema_name)
    _thread_locals.schema = schema_name


def activate_template_schema():
    """
    Activate the template schema.

    You probably don't want to do this. Sometimes you do (like for instance
    to apply migrations).
    """

    _thread_locals.schema = None
    schema_name = settings.TEMPLATE_SCHEMA
    schema_pre_activate.send(sender=None, schema_name=schema_name)
    _set_search_path(schema_name)
    if _get_search_path() != schema_name:

        raise SchemaNotFound('Template schema was not activated. It seems "{0}" is active.'.format(_get_search_path()))