# Path: ddah_web/models.py
# class DDAHSiteInstance(models.Model):
#     instance = models.OneToOneField(DDAHInstanceWeb)
#     site = models.OneToOneField(Site)
# 
#     def __unicode__(self):
#         dicti = {
#             'domain': self.site.domain,
#             'instance_title': self.instance.title
#         }
#         return u"{domain} redirects to {instance_title}".format(**dicti)


from ddah_web.models import DDAHSiteInstance


class DDAHSiteMiddleware(object):
    def process_request(self, request):
        if hasattr(request, 'instance') and request.instance is not None:
            return
        try:

# Path: ddah_web/models.py
# class DDAHSiteInstance(models.Model):
#     instance = models.OneToOneField(DDAHInstanceWeb)
#     site = models.OneToOneField(Site)
# 
#     def __unicode__(self):
#         dicti = {
#             'domain': self.site.domain,
#             'instance_title': self.instance.title
#         }
#         return u"{domain} redirects to {instance_title}".format(**dicti)


# Path: ddah_web/middleware.py
from ddah_web.models import DDAHSiteInstance



class DDAHSiteMiddleware(object):
    def process_request(self, request):
        if hasattr(request, 'instance') and request.instance is not None:
            return
        try:

            record = DDAHSiteInstance.objects.get(site__domain=request.get_host())