jazzband/django-hosts

LazySite 'shadows' Site name

gregbrowndev opened this issue · 0 comments

Using host_site callback in hosts.py, as per the documentation, e.g.

host_patterns = patterns('',
    host(r'www', settings.ROOT_URLCONF, name='www'),
    host(r'publish', 'publish.urls',
         callback='django_hosts.callbacks.host_site',
         name='publish'),
)

resolves and makes available the Site object for the host at request.site. However, the LazySite object that wraps the Site object shadows the name property of the Site record with the host name, i.e:

class LazySite(LazyObject):

    def __init__(self, request, *args, **kwargs):
        super(LazySite, self).__init__()
        self.__dict__.update({
            'name': request.host.name,
            'args': args,
            'kwargs': kwargs,
        })

    # other code ...

This means on the publish subdomain, accessing request.site.name returns the host name 'publish' (which can easily be accessed at request.host.name) rather then the site name, e.g. 'Publishing Service'.