Generate a links generation factory with the specified additional links.

    :param additional_links: A dict of link names to links to be added to the
           returned object.
    :returns: A link generation factory.
766033
def default_links_factory_with_additional(additional_links):
    
    def factory(pid, **kwargs):
        links = default_links_factory(pid)
        for link in additional_links:
            links[link] = additional_links[link].format(pid=pid,
                                                        scheme=request.scheme,
                                                        host=request.host)
        return links

    return factory
1057247
private function generateLink()
    {
        $extras = ['fieldType' => $this->fieldType];

        if ($this->files) {
            $extras['files'] = (bool) $this->files;
        }

        if ($this->filesOnly) {
            $extras['filesOnly'] = (bool) $this->filesOnly;
        }

        if ($this->path) {
            $extras['path'] = (string) $this->path;
        }

        if ($this->extensions) {
            $extras['extensions'] = (string) $this->extensions;
        }

        return System::getContainer()->get('contao.picker.builder')->getUrl('file', $extras);
    }
494589
def _add_links(self, links, key="href", proxy_key="proxyURL", endpoints=None):
        
        if endpoints is None:
            endpoints = ["likes", "replies", "shares", "self", "followers",
                         "following", "lists", "favorites", "members"]

        if links.get("links"):
            for endpoint in links['links']:
                # It would seem occasionally the links["links"][endpoint] is
                # just a string (what would be the href value). I don't know
                # why, it's likely a bug in pump.io but for now we'll support
                # this too.
                if isinstance(links['links'][endpoint], dict):
                    self._add_link(endpoint, links['links'][endpoint]["href"])
                else:
                    self._add_link(endpoint, links["links"][endpoint])

        for endpoint in endpoints:
            if links.get(endpoint, None) is None:
                continue

            if "pump_io" in links[endpoint]:
                self._add_link(endpoint, links[endpoint]["pump_io"][proxy_key])
            elif "url" in links[endpoint]:
                self._add_link(endpoint, links[endpoint]["url"])
            else:
                self._add_link(endpoint, links[endpoint][key])

        return self.links
1013116
def get_links(self, request=None):
        
        links = LinkNode()

        # Generate (path, method, view) given (path, method, callback).
        paths = []
        view_endpoints = []
        for path, method, callback in self.endpoints:
            view = self.create_view(callback, method, request)
            if getattr(view, 'exclude_from_schema', False):
                continue
            path = self.coerce_path(path, method, view)
            paths.append(path)
            view_endpoints.append((path, method, view))

        # Only generate the path prefix for paths that will be included
        if not paths:
            return None
        prefix = self.determine_path_prefix(paths)

        for path, method, view in view_endpoints:
            if not self.has_view_permissions(path, method, view):
                continue
            link = self.get_link(path, method, view, version=getattr(request, 'version', None))
            subpath = path[len(prefix):]
            keys = self.get_keys(subpath, method, view)
            try:
                insert_into(links, keys, link)
            except Exception:
                continue
        return links
967088
def _enrich_link(self, glossary):
        
        try:
            Model = apps.get_model(*glossary['link']['model'].split('.'))
            obj = Model.objects.get(pk=glossary['link']['pk'])
            glossary['link'].update(identifier=str(obj))
        except (KeyError, ObjectDoesNotExist):
            pass
749885
def linkify_with_escalations(self, escalations):
        
        for i in self:
            if not hasattr(i, 'escalations'):
                continue

            links_list = strip_and_uniq(i.escalations)
            new = []
            for name in [e for e in links_list if e]:
                escalation = escalations.find_by_name(name)
                if escalation is not None and escalation.uuid not in new:
                    new.append(escalation.uuid)
                else:
                    i.add_error("the escalation '%s' defined for '%s' is unknown"
                                % (name, i.get_name()))

            i.escalations = new
182066
def generate_additional_context(self, matching_datasets):
        """"""
        related_tags = Tag.objects.filter(
            dataset__in=matching_datasets
        ).distinct().annotate(
            Count('word')
        ).order_by('-word__count')[:5]

        return {
            'related_tags': related_tags
        }
30354
def linkify_s_by_plug(self):
        
        for module in self:
            new_modules = []
            for related in getattr(module, 'modules', []):
                related = related.strip()
                if not related:
                    continue
                o_related = self.find_by_name(related)
                if o_related is not None:
                    new_modules.append(o_related.uuid)
                else:
                    self.add_error("the module '%s' for the module '%s' is unknown!"
                                   % (related, module.get_name()))
            module.modules = new_modules
150085
def merge_link_object(serializer, data, instance):
    

    link_object = {}

    if not getattr(instance, 'pk', None):
        # If instance doesn't have a `pk` field, we'll assume it doesn't
        # have a canonical resource URL to hang a link off of.
        # This generally only affectes Ephemeral Objects.
        return data

    link_fields = serializer.get_link_fields()
    for name, field in six.iteritems(link_fields):
        # For included fields, omit link if there's no data.
        if name in data and not data[name]:
            continue

        link = getattr(field, 'link', None)
        if link is None:
            base_url = ''
            if settings.ENABLE_HOST_RELATIVE_LINKS:
                # if the resource isn't registered, this will default back to
                # using resource-relative urls for links.
                base_url = DynamicRouter.get_canonical_path(
                    serializer.get_resource_key(),
                    instance.pk
                ) or ''
            link = '%s%s/' % (base_url, name)
        # Default to DREST-generated relation endpoints.
        elif callable(link):
            link = link(name, field, data, instance)

        link_object[name] = link

    if link_object:
        data['links'] = link_object
    return data
526650
def default_links_pagination_factory(page, urlkwargs):
    """"""
    endpoint = '.communities_list'

    links = {
        'self': url_for(endpoint, page=page.page, _external=True, **urlkwargs),
    }

    if page.has_prev:
        links['prev'] = url_for(endpoint, page=page.prev_num, _external=True,
                                **urlkwargs)
    if page.has_next:
        links['next'] = url_for(endpoint, page=page.next_num, _external=True,
                                **urlkwargs)

    return links
19241
def include_extra_kwargs(self, kwargs, extra_kwargs):
        
        if extra_kwargs.get('read_only', False):
            for attr in [
                'required', 'default', 'allow_blank', 'allow_null',
                'min_length', 'max_length', 'min_value', 'max_value',
                'validators', 'queryset'
            ]:
                kwargs.pop(attr, None)

        if extra_kwargs.get('default') and kwargs.get('required') is False:
            kwargs.pop('required')

        if extra_kwargs.get('read_only', kwargs.get('read_only', False)):
            extra_kwargs.pop('required', None)  # Read only fields should always omit the 'required' argument.

        kwargs.update(extra_kwargs)

        return kwargs
1138697
def linkify_s_by_module(self, modules):
        
        for i in self:

            links_list = strip_and_uniq(i.modules)
            new = []
            for name in [e for e in links_list if e]:
                module = modules.find_by_name(name)
                if module is not None and module.uuid not in new:
                    new.append(module)
                else:
                    i.add_error("Error: the module %s is unknown for %s" % (name, i.get_name()))

            i.modules = new
1347618
def _additional(self, idents, kwargs):
        ''''''
        if kwargs:
            for name, value in list(kwargs.items()):
                if not isinstance(value, list):
                    raise ValueError('Additional arguments must be lists of \
same length as idents')
                for i in range(len(value)):
                    self[idents[i]][name] = value[i]
819176
def extra(self, **params):
        
        q = self._clone()
        for key, value in params.items():
            q._extra[key].append(value)
        return q
756122
def default_links_factory(pid, record=None, **kwargs):
    
    endpoint = '.{0}_item'.format(
        current_records_rest.default_endpoint_prefixes[pid.pid_type])
    links = dict(self=url_for(endpoint, pid_value=pid.pid_value,
                 _external=True))
    return links
1158911
private List<String> buildUrls(List<String> references) {
		List<String> urls = new ArrayList<String>(references.size());
		for (String url : references) {
			if (url.toUpperCase().startsWith("RFC")) {
				url = RFC_REFERENCE_BASE_URL + url;
			} else if (url.startsWith("http")) {
				// already an URL so do nothing
			} else {
				url = MIME_TYPE_REFERENCE_BASE_URL + "#" + url;
			}
			urls.add(url);
		}
		return urls;
	}
665039
def get_urls(self):
        
        urls = []

        for action in self.get_extra_actions():
            regex = r'^{}/$'.format(self._get_action_href(action))
            view = self.admin_site.admin_view(action)
            urls.append(url(regex, view))

        return urls + super(ExtraActionsMixin, self).get_urls()