当前位置: 首页>>代码示例>>Python>>正文


Python request.split_domain_port方法代码示例

本文整理汇总了Python中django.http.request.split_domain_port方法的典型用法代码示例。如果您正苦于以下问题:Python request.split_domain_port方法的具体用法?Python request.split_domain_port怎么用?Python request.split_domain_port使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.http.request的用法示例。


在下文中一共展示了request.split_domain_port方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_by_request

# 需要导入模块: from django.http import request [as 别名]
# 或者: from django.http.request import split_domain_port [as 别名]
def get_by_request(cls, request):
        domain = request.get_host()
        # Lookup by domain with/without port
        try:
            obj = cls.objects.get(domain=domain)
        except cls.DoesNotExist:
            # Lookup without port
            domain, _port = split_domain_port(domain)
            obj = cls.objects.get(domain=domain)
        return obj 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:12,代码来源:model_utils.py

示例2: _find_for_request

# 需要导入模块: from django.http import request [as 别名]
# 或者: from django.http.request import split_domain_port [as 别名]
def _find_for_request(request):
        hostname = split_domain_port(request.get_host())[0]
        port = request.get_port()
        site = None
        try:
            site = get_site_for_hostname(hostname, port)
        except Site.DoesNotExist:
            pass
            # copy old SiteMiddleware behavior
        return site 
开发者ID:wagtail,项目名称:wagtail,代码行数:12,代码来源:models.py

示例3: _get_site_by_request

# 需要导入模块: from django.http import request [as 别名]
# 或者: from django.http.request import split_domain_port [as 别名]
def _get_site_by_request(self, request):
        host = request.get_host()
        try:
            # First attempt to look up the site by host with or without port.
            if host not in SITE_CACHE:
                SITE_CACHE[host] = self.get(domain__iexact=host)
            return SITE_CACHE[host]
        except Site.DoesNotExist:
            # Fallback to looking up site after stripping port from the host.
            domain, port = split_domain_port(host)
            if not port:
                raise
            if domain not in SITE_CACHE:
                SITE_CACHE[domain] = self.get(domain__iexact=domain)
            return SITE_CACHE[domain] 
开发者ID:drexly,项目名称:openhgsenti,代码行数:17,代码来源:models.py

示例4: cc_validate_host

# 需要导入模块: from django.http import request [as 别名]
# 或者: from django.http.request import split_domain_port [as 别名]
def cc_validate_host(func):
    def validate(request):
        domain, port = split_domain_port(request.META['HTTP_HOST'])
        if not validate_host(domain, settings.CC_ALLOWED_HOSTS):
            return HttpResponseForbidden('forbiden')

        return func(request)

    return validate 
开发者ID:limpbrains,项目名称:django-cc,代码行数:11,代码来源:views.py

示例5: test_split_domain_port_removes_trailing_dot

# 需要导入模块: from django.http import request [as 别名]
# 或者: from django.http.request import split_domain_port [as 别名]
def test_split_domain_port_removes_trailing_dot(self):
        domain, port = split_domain_port('example.com.:8080')
        self.assertEqual(domain, 'example.com')
        self.assertEqual(port, '8080') 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:tests.py

示例6: __call__

# 需要导入模块: from django.http import request [as 别名]
# 或者: from django.http.request import split_domain_port [as 别名]
def __call__(self, request):
        domain, port = split_domain_port(request.get_host())

        try:
            current_site = Site.objects.get(domain=domain)
        except Site.DoesNotExist:
            current_site = Site.objects.get(id=settings.SITE_ID)

        request.site = current_site
        _thread_local.request = request

        return self.get_response(request) 
开发者ID:overshard,项目名称:timestrap,代码行数:14,代码来源:site.py


注:本文中的django.http.request.split_domain_port方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。