If object is proxied, return the proxy location URL.

        If object is local, return None.
322453
async def get_object_proxy_location(self, client, pid):
        
        try:
            return (await client.describe(pid)).get("DataONE-Proxy")
        except d1_common.types.exceptions.DataONEException:
            # Workaround for older GMNs that return 500 instead of 404 for describe()
            pass
467680
def get_url(self, obj):
        
        if not hasattr(obj, 'get_absolute_url') or not obj.get_absolute_url():
            raise ImproperlyConfigured("No URL configured. You must either \
set a ``get_absolute_url`` method on the %s model or override the %s view's \
``get_url`` method" % (obj.__class__.__name__, self.__class__.__name__))
        return obj.get_absolute_url()
1283998
function findProxyName(moduleName, proxyName, uri, callback) {
    var base = path.basename(moduleName),
        proxyUri = path.join(uri, proxyName, base)

    fs.stat(proxyUri, checkIfProxyExists)

    function checkIfProxyExists(err, stat) {
        if (err) {
            if (proxyUri.substr(-3, 3) === ".js") {
                proxyUri = proxyUri.substr(0, proxyUri.length - 3)
            } else {
                proxyUri = proxyUri + ".js"
            }

            fs.stat(proxyUri, checkIfChangedUriHelped)
        } else {

            callback(null, path.relative(uri, proxyUri))
        }
    }

    function checkIfChangedUriHelped(err, stat) {
        if (err) {
            moduleName = path.dirname(moduleName)

            findProxyName(moduleName, proxyName, uri, callback)
        } else {

            if (proxyUri.substr(-3, 3) === ".js")  {
                callback(null, path.relative(uri, proxyUri))
            } else {
                findProxyObject(uri, path.relative(uri, proxyUri),
                    callback)
            }
        }
    }
}
74056
def _uri(self, url):
        """"""
        if url and not url.startswith('/'):
            # Then this must be a proxy request.
            return url
        uri = "{0}://{1}{2}{3}".format(
            self._protocol,
            self.real_connection.host,
            self._port_postfix(),
            url,
        )
        return uri
800353
def modLocationPort(self, location):
        
        components = urlparse.urlparse(location)
        reverse_proxy_port = self.father.getHost().port
        reverse_proxy_host = self.father.getHost().host
        # returns an ordered dict of urlparse.ParseResult components
        _components = components._asdict()
        _components['netloc'] = '%s:%d' % (
            reverse_proxy_host, reverse_proxy_port
        )
        return urlparse.urlunparse(_components.values())
1206917
function isLocal(url) {
        var loc = document.location,
            reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + loc.protocol + "//" + loc.host);
        return url.match(reg);
      }
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
664191
private Node getNonProxyNode(IndexHits<Node> nodesFound)
    {
        Node node = null;
        if (nodesFound.hasNext())
        {
            node = nodesFound.next();
        }
        else
        {
            return null;
        }

        try
        {
            Object proxyNodeProperty = node.getProperty(PROXY_NODE_TYPE_KEY);
        }
        catch (NotFoundException e)
        {
            return node;
        }
        catch (IllegalStateException e)
        {
            return node;
        }
        return getNonProxyNode(nodesFound);
    }
36131
def object(self):
        """"""
        proxy = self._proxy
        return ObjectProxy(proxy.get_connection(),
                           proxy.get_name(),
                           proxy.get_object_path())
219950
def get_site_url():
    
    site_url = getattr(_THREAD_LOCAL, _THREAD_SITE_URL, None)
    if site_url is None:
        site_url = SITE_URL or get_site_url_()
        setattr(_THREAD_LOCAL, _THREAD_SITE_URL, site_url)

    return site_url
690967
def origin(self):
        
        # TODO: add a keyword-only option for keeping user/pass maybe?
        if not self.is_absolute():
            raise ValueError("URL should be absolute")
        if not self._val.scheme:
            raise ValueError("URL should have scheme")
        v = self._val
        netloc = self._make_netloc(None, None, v.hostname, v.port, encode=False)
        val = v._replace(netloc=netloc, path="", query="", fragment="")
        return URL(val, encoded=True)
971442
def get_location(self, obj):
        
        if not obj.city and not obj.country:
            return None
        elif obj.city and obj.country:
            return '%s, %s' % (obj.city, obj.country)
        elif obj.city or obj.country:
            return obj.city or obj.country
569989
def getObjectForProxy(self, proxy):
        
        obj = self.proxied_objects.get(id(proxy))

        if obj is None:
            from pyamf import flex

            obj = flex.unproxy_object(proxy)

            self.addProxyObject(obj, proxy)

        return obj
245133
def Proxy(f):
  """"""

  def Wrapped(self, *args):
    return getattr(self, f)(*args)

  return Wrapped
844328
def require_linklocal(handler):
    
    @functools.wraps(handler)
    async def decorated(request: web.Request) -> web.Response:
        ipaddr_str = request.headers.get('x-host-ip')
        invalid_req_data = {
            'error': 'bad-interface',
            'message': f'The endpoint {request.url} can only be used from '
            'local connections'
        }
        if not ipaddr_str:
            return web.json_response(
                data=invalid_req_data,
                status=403)
        try:
            addr = ipaddress.ip_address(ipaddr_str)
        except ValueError:
            LOG.exception(f"Couldn't parse host ip address {ipaddr_str}")
            raise

        if not addr.is_link_local:
            return web.json_response(data=invalid_req_data, status=403)

        return await handler(request)
    return decorated
715232
def objectproxy_realaddress(obj):
    
    voidp = QROOT.TPython.ObjectProxy_AsVoidPtr(obj)
    return C.addressof(C.c_char.from_buffer(voidp))
1001403
def do_proxy_failover(self, proxy_url, for_url):
        
        self._proxy_resolver.ban_proxy(proxy_url)
        return self._proxy_resolver.get_proxy_for_requests(for_url)