Same as `django.core.urlresolvers.reverse`, but optionally takes a request
    and returns a fully qualified URL, using the request to get the base URL.
552443
def _reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra):
    
    if format is not None:
        kwargs = kwargs or {}
        kwargs['format'] = format
    url = django_reverse(viewname, args=args, kwargs=kwargs, **extra)
    if request:
        return request.build_absolute_uri(url)
    return url
972375
def django_url(step, url=None):
    

    base_url = step.test.live_server_url

    if url:
        return urljoin(base_url, url)
    else:
        return base_url
619481
def to_url(self):
        """"""
        base_url = urlparse(self.url)

        query = parse_qs(base_url.query)
        for k, v in self.items():
            query.setdefault(k, []).append(to_utf8_optional_iterator(v))
        scheme = base_url.scheme
        netloc = base_url.netloc
        path = base_url.path
        params = base_url.params
        fragment = base_url.fragment

        url = (scheme, netloc, path, params, urlencode(query, True), fragment)
        return urlunparse(url)
643290
def retrieve(cls, *args, **kwargs):
        """"""
        return super(Reversal, cls).retrieve(*args, **kwargs)
704397
def get_redirect_url(self, *args, **kwargs):
        
        if self.url:
            url = self.url % kwargs
        elif self.pattern_name:
            try:
                url = reverse(self.pattern_name, args=args, kwargs=kwargs)
            except NoReverseMatch:
                return None
        else:
            return None
        return url
452611
def _get_url(self, url):
        """"""
        if self.base_url and not url.startswith(('http://', 'https://')):
            return urljoin(self.base_url, url)
        return url
460444
def get_resource_uri(self, obj):
        
        url = 'api:%s:%s-detail' % (
            self.api_version,
            getattr(
                self, 'resource_view_name',
                self.Meta.model._meta.model_name
            )
        )

        return reverse(url, request=self.context.get('request', None), kwargs={
            self.lookup_field: getattr(obj, self.lookup_field)
        })
1262
def get_forum_url(self):
        
        return reverse('forum:forum', kwargs={'slug': self.forum.slug, 'pk': self.forum.pk})
270748
def reverse(self, url, args=None, kwargs=None):
        '''  '''
        return reverse("%s:%s" % (self.instance_name, url,),
                        args=args,
                        kwargs=kwargs,
                        current_app = self.app_name)
66113
def get_url(self, obj, view_name, request, format):
        
        # Unsaved objects will not yet have a valid URL.
        if hasattr(obj, 'pk') and obj.pk in (None, ''):
            return None

        # default lookup from rest_framework.relations.HyperlinkedRelatedField
        lookup_value = getattr(obj, self.lookup_field)
        kwargs = {self.lookup_url_kwarg: lookup_value}

        # multi-level lookup
        for parent_lookup_kwarg in list(self.parent_lookup_kwargs.keys()):
            underscored_lookup = self.parent_lookup_kwargs[parent_lookup_kwarg]

            # split each lookup by their __, e.g. "parent__pk" will be split into "parent" and "pk", or
            # "parent__super__pk" would be split into "parent", "super" and "pk"
            lookups = underscored_lookup.split('__')

            # use the Django ORM to lookup this value, e.g., obj.parent.pk
            lookup_value = reduce(getattr, [obj] + lookups)

            # store the lookup_name and value in kwargs, which is later passed to the reverse method
            kwargs.update({parent_lookup_kwarg: lookup_value})

        return self.reverse(view_name, kwargs=kwargs, request=request, format=format)
468343
def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
    

    if not urlconf:
        urlconf = get_urlconf()
    resolver = get_resolver(urlconf)
    args = args or []
    kwargs = kwargs or {}

    prefix = get_script_prefix()

    if not isinstance(viewname, six.string_types):
        view = viewname
    else:
        parts = viewname.split(':')
        parts.reverse()
        view = parts[0]
        path = parts[1:]

        resolved_path = []
        ns_pattern = ''
        while path:
            ns = path.pop()

            # Lookup the name to see if it could be an app identifier
            try:
                app_list = resolver.app_dict[ns]
                # Yes! Path part matches an app in the current Resolver
                if current_app and current_app in app_list:
                    # If we are reversing for a particular app,
                    # use that namespace
                    ns = current_app
                elif ns not in app_list:
                    # The name isn't shared by one of the instances
                    # (i.e., the default) so just pick the first instance
                    # as the default.
                    ns = app_list[0]
            except KeyError:
                pass

            try:
                extra, resolver = resolver.namespace_dict[ns]
                resolved_path.append(ns)
                ns_pattern = ns_pattern + extra
            except KeyError as key:

                for urlconf, config in six.iteritems(
                        ApplicationWidget._feincms_content_models[0].ALL_APPS_CONFIG):

                    partials = viewname.split(':')
                    app = partials[0]
                    partials = partials[1:]

                    # check if namespace is same as app name and try resolve
                    if urlconf.split(".")[-1] == app:

                        try:
                            return app_reverse(
                                ':'.join(partials),
                                urlconf, args=args, kwargs=kwargs,
                                current_app=current_app)
                        except NoReverseMatch:
                            pass

                if resolved_path:
                    raise NoReverseMatch(
                        "%s is not a registered namespace inside '%s'" %
                        (key, ':'.join(resolved_path)))
                else:
                    raise NoReverseMatch("%s is not a registered namespace" %
                                         key)
        if ns_pattern:
            resolver = get_ns_resolver(ns_pattern, resolver)

    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
393486
def root_endpoint(request, format=None):
    
    endpoints = []
    # loop over url modules
    for urlmodule in urlpatterns:
        # is it a urlconf module?
        if hasattr(urlmodule, 'urlconf_module'):
            is_urlconf_module = True
        else:
            is_urlconf_module = False
        # if url is really a urlmodule
        if is_urlconf_module:
            # loop over urls of that module
            for url in urlmodule.urlconf_module.urlpatterns:
                # TODO: configurable skip url in settings
                # skip api-docs url
                if url.name in ['django.swagger.resources.view']:
                    continue
                # try adding url to list of urls to show
                try:
                    endpoints.append({
                        'name': url.name.replace('api_', ''),
                        'url': reverse(url.name, request=request, format=format)
                    })
                # urls of object details will fail silently (eg: /nodes/<slug>/)
                except NoReverseMatch:
                    pass
    return Response(endpoints)
523797
def _make_full_url(self, url):
        

        return SLASH.join([self._api_base_url, url.lstrip(SLASH)])
957119
def get_absolute_url(self):
        
        if not self.tree_parent_id:
            url = reverse('root_homepage')
        else:
            url = reverse('category_detail', kwargs={'category' : self.tree_path})
        if self.site_id != settings.SITE_ID:
            # prepend the domain if it doesn't match current Site
            return 'http://' + self.site.domain + url
        return url
668403
def url(self, name, *, base=None, query=None, **match):
        
        return self.__router.url(name, base=base, query=query, **match)
411631
def get_service_url(request, redirect_to=None):
    """"""
    if hasattr(django_settings, 'CAS_ROOT_PROXIED_AS'):
        service = django_settings.CAS_ROOT_PROXIED_AS + request.path
    else:
        protocol = get_protocol(request)
        host = request.get_host()
        service = urllib_parse.urlunparse(
            (protocol, host, request.path, '', '', ''),
        )
    if not django_settings.CAS_STORE_NEXT:
        if '?' in service:
            service += '&'
        else:
            service += '?'
        service += urllib_parse.urlencode({
            REDIRECT_FIELD_NAME: redirect_to or get_redirect_url(request)
        })
    return service
693414
def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra):
    
    scheme = getattr(request, 'versioning_scheme', None)
    if scheme is not None:
        try:
            url = scheme.reverse(viewname, args, kwargs, request, format, **extra)
        except NoReverseMatch:
            # In case the versioning scheme reversal fails, fallback to the
            # default implementation
            url = _reverse(viewname, args, kwargs, request, format, **extra)
    else:
        url = _reverse(viewname, args, kwargs, request, format, **extra)

    return preserve_builtin_query_params(url, request)