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()
            try:
                app_list = resolver.app_dict[ns]
                if current_app and current_app in app_list:
                    ns = current_app
                elif ns not in app_list:
                    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:]
                    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))