Exemplo n.º 1
0
 def test_url_join(self):
     self.assertEqual(urljoin(self.DOMAIN, scheme='http'),
         'http://%s' % self.DOMAIN)
     self.assertEqual(urljoin(self.DOMAIN, scheme='https'),
         'https://%s' % self.DOMAIN)
     self.assertEqual(urljoin(self.DOMAIN, scheme='http', path='/example/'),
         'http://%s/example/' % self.DOMAIN)
Exemplo n.º 2
0
 def test_url_join(self):
     self.assertEqual(urljoin(self.DOMAIN, scheme='http'),
                      'http://%s' % self.DOMAIN)
     self.assertEqual(urljoin(self.DOMAIN, scheme='https'),
                      'https://%s' % self.DOMAIN)
     self.assertEqual(urljoin(self.DOMAIN, scheme='http', path='/example/'),
                      'http://%s/example/' % self.DOMAIN)
Exemplo n.º 3
0
    def test_url_join(self):
        self.assertEqual(urljoin(self.DOMAIN), 'http://%s' % self.DOMAIN)
        self.assertEqual(urljoin(self.DOMAIN, scheme='https'),
            'https://%s' % self.DOMAIN)

        with override_settings(DEFAULT_URL_SCHEME='https'):
            self.assertEqual(urljoin(self.DOMAIN), 'https://%s' % self.DOMAIN)

        self.assertEqual(urljoin(self.DOMAIN, path='/example/'),
            'http://%s/example/' % self.DOMAIN)
Exemplo n.º 4
0
    def test_url_join(self):
        self.assertEqual(urljoin(self.DOMAIN), 'http://%s' % self.DOMAIN)
        self.assertEqual(urljoin(self.DOMAIN, scheme='https'),
                         'https://%s' % self.DOMAIN)

        with override_settings(DEFAULT_URL_SCHEME='https'):
            self.assertEqual(urljoin(self.DOMAIN), 'https://%s' % self.DOMAIN)

        self.assertEqual(urljoin(self.DOMAIN, path='/example/'),
                         'http://%s/example/' % self.DOMAIN)
Exemplo n.º 5
0
def reverse(viewname, subdomain=None, scheme=None, args=None, kwargs=None,
        current_app=None):
    """
    Reverses a URL from the given parameters, in a similar fashion to
    :meth:`django.core.urlresolvers.reverse`.

    :param viewname: the name of URL
    :param subdomain: the subdomain to use for URL reversing
    :param scheme: the scheme to use when generating the full URL
    :param args: positional arguments used for URL reversing
    :param kwargs: named arguments used for URL reversing
    :param current_app: hint for the currently executing application
    """
    urlconf = settings.SUBDOMAIN_URLCONFS.get(subdomain, settings.ROOT_URLCONF)

    domain = get_domain()
    if subdomain is not None:
        domain = '%s.%s' % (subdomain, domain)

    path = simple_reverse(viewname, urlconf=urlconf, args=args, kwargs=kwargs,
        current_app=current_app)
    return urljoin(domain, path, scheme=scheme)