Get the first children URN for a given resource

        :param reference: CtsReference from which to find child (If None, find first reference)
        :type reference: CtsReference, str
        :return: Children URN
        :rtype: URN
777826
def getFirstUrn(self, reference=None):
        
        if reference is not None:
            if ":" in reference:
                urn = reference
            else:
                urn = "{}:{}".format(
                    str(URN(str(self.urn)).upTo(URN.NO_PASSAGE)),
                    str(reference)
                )
        else:
            urn = str(self.urn)
        _first = _SharedMethod.firstUrn(
            self.retriever.getFirstUrn(
                urn
            )
        )
        return _first
1197798
def get_backreferences_for(self, instance):
        
        rc = api.get_tool("reference_catalog")
        backreferences = rc.getReferences(instance, self.relationship)
        return map(lambda ref: ref.targetUID, backreferences)
545848
def get_ref(self):
        
        if self.ref_key == 'NETWORK':
            return self.network
        elif self.ref_key == 'NODE':
            return self.node
        elif self.ref_key == 'LINK':
            return self.link
        elif self.ref_key == 'GROUP':
            return self.group
        elif self.ref_key == 'SCENARIO':
            return self.scenario
        elif self.ref_key == 'PROJECT':
            return self.project
588955
def nextId(self):
        
        if self._next_id is False:
            # Request the next urn
            self._prev_id, self._next_id = self.getPrevNextUrn(reference=self.urn.reference)
        return self._next_id
1018810
def _add_referencer(registry):
    
    referencer = registry.queryUtility(IReferencer)
    if referencer is not None:
        return referencer
    ref = registry.settings['urireferencer.referencer']
    url = registry.settings['urireferencer.registry_url']
    r = DottedNameResolver()
    registry.registerUtility(r.resolve(ref)(url), IReferencer)
    return registry.queryUtility(IReferencer)
44324
def get_referencer(registry):
    
    # Argument might be a config or request
    regis = getattr(registry, 'registry', None)
    if regis is None:
        regis = registry
    return regis.queryUtility(IReferencer)
780487
def locateChild(self, context, segments):
        
        childDeferred = maybeDeferred(
            self.wrappedResource.locateChild, context, segments)
        def childLocated((resource, segments)):
            if (resource, segments) == NotFound:
                return NotFound
            return _SecureWrapper(self.urlGenerator, resource), segments
        childDeferred.addCallback(childLocated)
        return childDeferred
573445
def get_children(self, root=None, target=None):
        
        if root is None:
            print("Warning: TreeCtrl root/child must be given.")
            return None
        if target is None:
            print("Warning: TreeCtrl target must be given.")
            return None
        child, cookie = target.GetFirstChild(root)
        child_list = []
        while child.IsOk():
            if target.ItemHasChildren(child):
                child_list.extend(self.get_children(child, target))
            child_list.append(child)
            child, cookie = target.GetNextChild(root, cookie)
        return child_list
384090
def _get_valid_reff(self, urn, level):
        
        urn = URN(urn)
        subreference = None
        textId=urn.upTo(URN.NO_PASSAGE)
        if urn.reference is not None:
            subreference = str(urn.reference)
        reffs = self.resolver.getReffs(textId=textId, subreference=subreference, level=level)
        r = render_template(
            "cts/GetValidReff.xml",
            reffs=reffs,
            urn=textId,
            level=level,
            request_urn=str(urn)
        )
        return r, 200, {"content-type": "application/xml"}
189987
def do_reference(self, parent=None, ident=0):
        
        (handle,) = self._readStruct(">L")
        log_debug("## Reference handle: 0x{0:X}".format(handle), ident)
        ref = self.references[handle - self.BASE_REFERENCE_IDX]
        log_debug("###-> Type: {0} - Value: {1}".format(type(ref), ref), ident)
        return ref
406785
def firstUrn(resource):
        
        resource = xmlparser(resource)
        urn = resource.xpath("//ti:reply/ti:urn/text()", namespaces=XPATH_NAMESPACES, magic_string=True)

        if len(urn) > 0:
            urn = str(urn[0])
            return urn.split(":")[-1]
207510
def visit_reference(self, node: docutils.nodes.reference) -> None:
        """"""
        # if len(node.children) != 1 or not isinstance(node.children[0], docutils.nodes.Text) \
        #         or not all(_ in node.attributes for _ in ('name', 'refuri')):
        #     return
        path = pathlib.Path(node.attributes['refuri'])
        try:
            if path.is_absolute():
                return
            resolved_path = path.resolve()
        except FileNotFoundError:  # in resolve(), prior to Python 3.6
            return
        # except OSError:  # in is_absolute() and resolve(), on URLs in Windows
        #     return
        try:
            resolved_path.relative_to(HERE)
        except ValueError:
            return
        if not path.is_file():
            return
        assert node.attributes['name'] == node.children[0].astext()
        self.references.append(node)
1317931
def locateChild(self, context, segments):
        
        request = IRequest(context)
        if request.isSecure():
            return self.wrappedResource, segments
        return _SecureWrapper(self.urlGenerator, self.wrappedResource), segments
1136778
def get_children_to_delete(self):
        
        refobjinter = self.get_refobjinter()
        children = self.get_all_children()

        todelete = []
        for c in children:
            if c.status() is None:
                # if child is not in scene we do not have to delete it
                continue
            rby = refobjinter.referenced_by(c.get_refobj())
            if rby is None:
                # child is not part of another reference.
                # we have to delete it for sure
                todelete.append(c)
                continue
            # check if child is referenced by any parent up to self
            # if it is not referenced by any refrence of a parent, then we
            # can assume it is referenced by a parent of a greater scope,
            # e.g. the parent of self. because we do not delete anything above self
            # we would have to delete the child manually
            parent = c.get_parent()
            while parent != self.get_parent():
                if refobjinter.get_reference(parent.get_refobj()) == rby:
                    # is referenced by a parent so it will get delted when the parent is deleted.
                    break
                parent = parent.get_parent()
            else:
                todelete.append(c)
        return todelete
113817
def locateChild(self, context, segments):
        
        request = IRequest(context)
        hostname = request.getHeader('host')

        info = self.subdomain(hostname)
        if info is not None:
            username, domain = info
            index = UserIndexPage(IRealm(self.siteStore),
                                  self.webViewer)
            resource = index.locateChild(None, [username])[0]
            return resource, segments
        return self.wrapped.locateChild(context, segments)
770827
def get_objects_in_sequence(brain_or_object, ctype, cref):
    
    obj = api.get_object(brain_or_object)
    if ctype == "backreference":
        return get_backreferences(obj, cref)
    if ctype == "contained":
        return get_contained_items(obj, cref)
    raise ValueError("Reference value is mandatory for sequence type counter")
337260
def get_referenced_object(self):
        

        if self._TabUsageSingle is not None:
            return self._TabUsageSingle

        if self._TabUsageMultiple is not None:
            return self._TabUsageMultiple

        raise exception.BunqException(self._ERROR_NULL_FIELDS)